Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: aggregation interval #203

Merged
merged 3 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/server/controllers/item/shared/extra-intervals-mapping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable @typescript-eslint/no-magic-numbers */
export const extraIntervalMilliseconds = new Map([
["5 seconds", 5000],
["10 seconds", 10000],
["30 seconds", 30000],
["1 minute", 60000],
["5 minute", 300000],
["10 minutes", 600000],
["30 minutes", 1800000],
["1 hour", 3600000],
])
4 changes: 3 additions & 1 deletion src/server/controllers/item/shared/item-data-processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ReportStatus } from "../../../queries/items.model"
import { getScenarioSettings, currentScenarioMetrics } from "../../../queries/scenario"
import { sendNotifications } from "../../../utils/notifications/send-notification"
import { scenarioThresholdsCalc } from "../utils/scenario-thresholds-calc"
import { extraIntervalMilliseconds } from "./extra-intervals-mapping"

export const itemDataProcessing = async ({ projectName, scenarioName, itemId }) => {
const MAX_LABEL_CHART_LENGTH = 100000
Expand Down Expand Up @@ -71,6 +72,7 @@ export const itemDataProcessing = async ({ projectName, scenarioName, itemId })
const overviewChart = await db.many(chartOverviewQuery(interval, itemId))
const statusCodeChart = await db.many(chartOverviewStatusCodesQuery(interval, itemId))
if (parseInt(index, 10) === 0) { // default interval
console.log(overviewChart)
chartData = prepareChartDataForSaving(
{
overviewData: overviewChart,
Expand All @@ -84,7 +86,7 @@ export const itemDataProcessing = async ({ projectName, scenarioName, itemId })
{
overviewData: overviewChart,
labelData: labelChart,
interval: defaultInterval,
interval: extraIntervalMilliseconds.get(interval),
distributedThreads,
statusCodeData: statusCodeChart,
})
Expand Down