Skip to content

Commit

Permalink
Update clickhouse query to /views/now (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko committed Mar 25, 2024
1 parent e1c52d8 commit 69beb91
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions views/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ func (c *ClickhouseClient) QueryTimeSeriesRealtimeViewsEvents(ctx context.Contex
func buildRealtimeViewsEventsQuery(spec QuerySpec) (string, []interface{}, error) {
query := squirrel.Select(
"count(distinct session_id) as view_count",
"count(distinct if(JSONExtractInt(event_data, 'errors') > 0, session_id, null)) / count(distinct session_id) as error_rate").
From("viewership_events").
"count(distinct if(errors > 0, session_id, null)) / count(distinct session_id) as error_rate").
From("viewership_current_counts").
Where("user_id = ?", spec.Filter.UserID).
Where("server_timestamp > (toUnixTimestamp(now() - 30)) * 1000").
Limit(maxClickhouseResultRows + 1)
return toSqlWithFiltersAndBreakdown(query, spec)
}
Expand Down

0 comments on commit 69beb91

Please sign in to comment.