From 3a69666cd084b60c6ea500e8acd2bbea8bb6716f Mon Sep 17 00:00:00 2001 From: Matt Rogers <42357482+twitchyvr@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:16:39 -0700 Subject: [PATCH] working --- src/index.js | 27 +++++++++++++++++++++++++++ src/utils/telemetry-file-loader.js | 13 ------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/index.js b/src/index.js index 5e66513..176570a 100644 --- a/src/index.js +++ b/src/index.js @@ -33,6 +33,7 @@ module.exports = async function (context, req) { // console.log(telemetry.header) >>>>>>> parent of 9cac5f7 (multiple updates) +<<<<<<< HEAD context.res = { status: 200, body: telemetrySummary @@ -40,6 +41,32 @@ module.exports = async function (context, req) { } catch (telemetryError) { context.log.error('Error processing telemetry:', telemetryError) throw telemetryError // Rethrow to be caught by outer catch +======= + /** + // Example: Create a summary or extract specific data from telemetry + const telemetrySummary = { + uniqueId: telemetry.uniqueId(), + header: telemetry.header, + sessionInfo: telemetry.sessionInfo, + varHeaders: telemetry.varHeaders, + telemetryData: telemetry.data + // Add other telemetry properties or summaries here + } + */ + + const telemetrySummary = { + uniqueId: telemetry.uniqueId(), + header: telemetry.headers, // Assuming this contains the parsed header data + sessionInfo: telemetry.sessionInfo, // Contains the parsed YAML session info + varHeaders: telemetry.varHeaders, // Assuming this method returns the variable headers + telemetryData: telemetry.getTelemetryDataSummary() + } + + // Response + context.res = { + status: 200, + body: telemetrySummary +>>>>>>> parent of 84efee0 (we have some working output) } } catch (error) { context.res = { diff --git a/src/utils/telemetry-file-loader.js b/src/utils/telemetry-file-loader.js index 5c763dc..99cb541 100644 --- a/src/utils/telemetry-file-loader.js +++ b/src/utils/telemetry-file-loader.js @@ -45,27 +45,14 @@ const sessionInfoStringFromFileDescriptor = (fd, telemetryHeader) => { } const varHeadersFromFileDescriptor = (fd, telemetryHeader) => { - // Add logging - console.log('Num vars:', telemetryHeader.numVars) if (!isNumber(telemetryHeader.numVars, 'numVars')) { return Promise.reject(new Error('Invalid number of variables (numVars)')) } const numberOfVariables = telemetryHeader.numVars const startPosition = telemetryHeader.varHeaderOffset - - // Add check before using in buffer size - if (!isNumber(numberOfVariables)) { - return Promise.reject(new Error('Invalid numVars')) - } - const fullBufferSize = numberOfVariables * VAR_HEADER_SIZE_IN_BYTES - // Add check before passing to read buffer - if (!isNumber(fullBufferSize)) { - return Promise.reject(new Error('Invalid buffer size')) - } - return readFileToBuffer(fd, startPosition, fullBufferSize) .then(buffer => { return R.range(0, numberOfVariables).map(count => {