zerofill analytics
This commit is contained in:
parent
2d6da8343d
commit
9940e9dd90
1 changed files with 6 additions and 1 deletions
|
@ -24,7 +24,7 @@ impl Analytics {
|
||||||
) -> Vec<Event> {
|
) -> Vec<Event> {
|
||||||
let pool = ctx.data::<Pool<Postgres>>().unwrap();
|
let pool = ctx.data::<Pool<Postgres>>().unwrap();
|
||||||
|
|
||||||
let sql = format!("SELECT time_bucket('{} seconds', time) AS bucket, count(*), event_name, world_id FROM analytics WHERE time > now() - interval '{}' {} GROUP BY bucket, world_id, event_name ORDER BY bucket ASC",
|
let sql = format!("SELECT time_bucket_gapfill('{} seconds', time, start => now() - '{}'::interval, finish => now()) AS bucket, CASE WHEN count(*) IS NULL THEN 0 ELSE count(*) END AS count, event_name, world_id FROM analytics WHERE time > now() - '{}'::interval {} GROUP BY bucket, world_id, event_name ORDER BY bucket ASC",
|
||||||
if hi_precision {
|
if hi_precision {
|
||||||
5
|
5
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,6 +35,11 @@ impl Analytics {
|
||||||
} else {
|
} else {
|
||||||
"1 day"
|
"1 day"
|
||||||
},
|
},
|
||||||
|
if hi_precision {
|
||||||
|
"1 hour"
|
||||||
|
} else {
|
||||||
|
"1 day"
|
||||||
|
},
|
||||||
if let Some(world_id) = world_id {
|
if let Some(world_id) = world_id {
|
||||||
format!("AND world_id = {}", world_id)
|
format!("AND world_id = {}", world_id)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue