Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: fixes timestamp truncation filtering logic, to ensure correct timestamp filtering

TzeYiing2e51b205555c
diff --git a/studio/components/interfaces/Settings/Logs/Logs.utils.ts b/studio/components/interfaces/Settings/Logs/Logs.utils.ts
index 2c2f2f58200..e008c1829f5 100644
--- a/studio/components/interfaces/Settings/Logs/Logs.utils.ts
+++ b/studio/components/interfaces/Settings/Logs/Logs.utils.ts
@@ -174,13 +174,13 @@ export const calcChartStart = (params: Partial<LogsEndpointParams>): [Dayjs, str
const ite = params.iso_timestamp_end ? dayjs(params.iso_timestamp_end) : dayjs()
const its = params.iso_timestamp_start ? dayjs(params.iso_timestamp_start) : dayjs()
let trunc = 'minute'
- let extendValue = 60 * 6
+ let extendValue = 60 * 1
const minuteDiff = ite.diff(its, 'minute')
const hourDiff = ite.diff(its, 'hour')
- if (minuteDiff > (60 * 12)) {
+ if (minuteDiff > (60 * 8)) {
trunc = 'hour'
extendValue = 24 * 3
- } else if (hourDiff > 24 * 5) {
+ } else if (hourDiff > 24 * 3) {
trunc = 'day'
extendValue = 7
}
@@ -198,13 +198,15 @@ export const genChartQuery = (
) => {
const [startOffset, trunc] = calcChartStart(params)
const where = _genWhereStatement(table, filters)
+ console.log('where', where)
return `
SELECT
timestamp_trunc(t.timestamp, ${trunc}) as timestamp,
- count(timestamp) as count
+ count(t.timestamp) as count
FROM
${table} t
-${where ? where + ` and t.timestamp > '${startOffset.toISOString()}'` : ""}
+ cross join unnest(t.metadata) as metadata
+ ${where ? where + ` and t.timestamp > '${startOffset.toISOString()}'` : `where t.timestamp > '${startOffset.toISOString()}'`}
GROUP BY
timestamp
ORDER BY