Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
twitchyvr committed Nov 26, 2023
1 parent 7d6921b commit 3a69666
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
27 changes: 27 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,40 @@ module.exports = async function (context, req) {
// console.log(telemetry.header)
>>>>>>> parent of 9cac5f7 (multiple updates)

<<<<<<< HEAD
context.res = {
status: 200,
body: telemetrySummary
}
} 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 = {
Expand Down
13 changes: 0 additions & 13 deletions src/utils/telemetry-file-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 3a69666

Please sign in to comment.