Skip to content

Commit

Permalink
hotfix: granularity charts display
Browse files Browse the repository at this point in the history
  • Loading branch information
arielweinberger committed Dec 31, 2023
1 parent 8111573 commit c224dfd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/server/src/app/metrics/queries/queries.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ export const generateBucketsSubquery = (
const subquery = knex
.select(
knex.raw(
`${timeProps.roundFn}(parseDateTimeBestEffort(?) + INTERVAL number hour) AS timestamp`,
`${timeProps.roundFn}(parseDateTimeBestEffort(?) + INTERVAL number ${timeProps.interval}) AS timestamp`,
[startDate]
)
)
.from(
knex.raw(
"numbers(dateDiff('hour', parseDateTimeBestEffort(?), parseDateTimeBestEffort(?)) + 1)",
`numbers(dateDiff('${timeProps.interval}', parseDateTimeBestEffort(?), parseDateTimeBestEffort(?)) + 1)`,
[startDate, endDate]
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ export const successErrorRateQuery = (
.with("buckets", bucketsSubquery)
.select({
timestamp: "b.timestamp",
requests: knex.raw("count(*)"),
requests: knex.raw(
`countIf(${timeProps.roundFn}(r.requestTimestamp) = timestamp)`
),
error: knex.raw(
"countIf(r.isError = true AND toStartOfHour(r.requestTimestamp) = timestamp)"
`countIf(r.isError = true AND ${timeProps.roundFn}(r.requestTimestamp) = timestamp)`
),
success: knex.raw(
"countIf(r.isError = false AND toStartOfHour(r.requestTimestamp) = timestamp)"
`countIf(r.isError = false AND ${timeProps.roundFn}(r.requestTimestamp) = timestamp)`
),
})
.from("buckets as b")
Expand Down

0 comments on commit c224dfd

Please sign in to comment.