Skip to content

Commit c224dfd

Browse files
hotfix: granularity charts display
1 parent 8111573 commit c224dfd

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

apps/server/src/app/metrics/queries/queries.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ export const generateBucketsSubquery = (
3636
const subquery = knex
3737
.select(
3838
knex.raw(
39-
`${timeProps.roundFn}(parseDateTimeBestEffort(?) + INTERVAL number hour) AS timestamp`,
39+
`${timeProps.roundFn}(parseDateTimeBestEffort(?) + INTERVAL number ${timeProps.interval}) AS timestamp`,
4040
[startDate]
4141
)
4242
)
4343
.from(
4444
knex.raw(
45-
"numbers(dateDiff('hour', parseDateTimeBestEffort(?), parseDateTimeBestEffort(?)) + 1)",
45+
`numbers(dateDiff('${timeProps.interval}', parseDateTimeBestEffort(?), parseDateTimeBestEffort(?)) + 1)`,
4646
[startDate, endDate]
4747
)
4848
);

apps/server/src/app/metrics/queries/success-error-rate-query.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ export const successErrorRateQuery = (
2727
.with("buckets", bucketsSubquery)
2828
.select({
2929
timestamp: "b.timestamp",
30-
requests: knex.raw("count(*)"),
30+
requests: knex.raw(
31+
`countIf(${timeProps.roundFn}(r.requestTimestamp) = timestamp)`
32+
),
3133
error: knex.raw(
32-
"countIf(r.isError = true AND toStartOfHour(r.requestTimestamp) = timestamp)"
34+
`countIf(r.isError = true AND ${timeProps.roundFn}(r.requestTimestamp) = timestamp)`
3335
),
3436
success: knex.raw(
35-
"countIf(r.isError = false AND toStartOfHour(r.requestTimestamp) = timestamp)"
37+
`countIf(r.isError = false AND ${timeProps.roundFn}(r.requestTimestamp) = timestamp)`
3638
),
3739
})
3840
.from("buckets as b")

0 commit comments

Comments
 (0)