-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple caching and sending data in interval mechanism, touch #456.
- Loading branch information
Showing
13 changed files
with
206 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"boost": null, | ||
"chart": { | ||
"type": null, | ||
"options3d": { | ||
"enabled": null | ||
} | ||
}, | ||
"colors": null, | ||
"legend": { | ||
"enabled": null | ||
}, | ||
"series": { | ||
"type": null | ||
}, | ||
"xAxis": { | ||
"type": null | ||
}, | ||
"yAxis": { | ||
"type": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/******************************************************************************* | ||
Highcharts Export Server | ||
Copyright (c) 2016-2023, Highsoft | ||
Licenced under the MIT licence. | ||
Additionally a valid Highcharts license is required for use. | ||
See LICENSE file in root for details. | ||
*******************************************************************************/ | ||
|
||
import { readFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
import { __dirname } from './utils.js'; | ||
|
||
// Get the telemetry template | ||
const telemetryTemplate = JSON.parse( | ||
readFileSync(join(__dirname, 'lib', 'schemas', 'telemetry.json')) | ||
); | ||
|
||
// The object with telemetry data collected | ||
export const telemetryData = { | ||
numberOfRequests: 0 | ||
}; | ||
|
||
// Possible properties in an array | ||
const optionsInArray = ['series', 'xAxis', 'yAxis', 'zAxis']; | ||
|
||
// Recursive function for getting only the required options | ||
function filterData(template, options) { | ||
const filteredObject = {}; | ||
|
||
// Cycle through allowed propeties | ||
for (const [templateKey, templateValue] of Object.entries(template)) { | ||
// Check if the section exists | ||
if (options[templateKey] !== undefined) { | ||
// Check if this is the final level of indent in the template | ||
if (templateValue !== null) { | ||
// Check if it is an array | ||
if (Array.isArray(options[templateKey])) { | ||
// And if it contains allowed properties | ||
if (optionsInArray.includes(templateKey)) { | ||
// Create an array | ||
filteredObject[templateKey] = []; | ||
// If so, cycle through all of them | ||
for (const [index, optionsValue] of options[ | ||
templateKey | ||
].entries()) { | ||
filteredObject[templateKey][index] = filterData( | ||
templateValue, | ||
optionsValue | ||
); | ||
} | ||
} else { | ||
// Otherwise, get only the first element | ||
filteredObject[templateKey] = filterData( | ||
templateValue, | ||
options[templateKey][0] | ||
); | ||
} | ||
} else { | ||
filteredObject[templateKey] = filterData( | ||
templateValue, | ||
options[templateKey] | ||
); | ||
} | ||
} else { | ||
// Return the option | ||
filteredObject[templateKey] = options[templateKey]; | ||
} | ||
} | ||
} | ||
|
||
// Return the object | ||
return filteredObject; | ||
} | ||
|
||
export function prepareTelemetry(chartOptions, requestId) { | ||
// Save the filtered options under the request's id | ||
telemetryData[requestId] = filterData(telemetryTemplate, chartOptions); | ||
|
||
// Increment requests counter | ||
telemetryData.numberOfRequests++; | ||
} | ||
|
||
export default { | ||
telemetryData, | ||
prepareTelemetry | ||
}; |
Oops, something went wrong.