Skip to content

Commit

Permalink
feat: change field names on timeseries_hour_group_count query
Browse files Browse the repository at this point in the history
  • Loading branch information
helllllllder committed Jun 13, 2024
1 parent 31d3da3 commit cc7ab9b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion insights/sources/rooms/query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def timeseries_hour_group_count(
):
if not self.is_valid:
self.build_query()
query = f"WITH hourly_data AS (SELECT EXTRACT(HOUR FROM r.{time_field}) AS hour, COUNT(*) AS rooms_count FROM public.rooms_room as r {self.join_clause} WHERE {self.where_clause} GROUP BY hour) SELECT hours.hour as label, COALESCE(hourly_data.rooms_count, 0) AS value FROM generate_series(0, 23) AS hours(hour) LEFT JOIN hourly_data ON label = hourly_data.hour ORDER BY value DESC FETCH FIRST {limit} ROWS ONLY;"
query = f"WITH hourly_data AS (SELECT EXTRACT(HOUR FROM r.{time_field}) AS hour, COUNT(*) AS rooms_count FROM public.rooms_room as r {self.join_clause} WHERE {self.where_clause} GROUP BY hour) SELECT hours.label, COALESCE(hourly_data.rooms_count, 0) AS value FROM generate_series(0, 23) AS hours(label) LEFT JOIN hourly_data ON hours.label = hourly_data.hour ORDER BY value DESC FETCH FIRST {limit} ROWS ONLY;"

return query, self.params

Expand Down

0 comments on commit cc7ab9b

Please sign in to comment.