fix postgres timeframe

pull/958/head
Jakub Janata 2021-02-06 21:52:29 +01:00
parent b6ca1a5c66
commit 354c28a70f
No known key found for this signature in database
GPG Key ID: 8F60A9AA857B1A75
1 changed files with 1 additions and 1 deletions

View File

@ -36,7 +36,7 @@ func (it *Db) SelectByTime(increment time.Duration) string {
case "mysql":
return fmt.Sprintf("FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(created_at) / %d) * %d) AS timeframe", seconds, seconds)
case "postgres":
return fmt.Sprintf("date_trunc('minute', created_at) - (CAST(EXTRACT(MINUTE FROM created_at) AS integer) %% %d) * interval '1 minute' AS timeframe", seconds)
return fmt.Sprintf("date_trunc('minute', created_at) - (CAST(EXTRACT(MINUTE FROM created_at) AS integer) %% %d) * interval '1 minute' AS timeframe", int64(increment.Minutes()))
default:
return fmt.Sprintf("datetime((strftime('%%s', created_at) / %d) * %d, 'unixepoch') as timeframe", seconds, seconds)
}