Skip to content

Commit

Permalink
feat: add coalasce over avg to stop returnin null values
Browse files Browse the repository at this point in the history
  • Loading branch information
helllllllder committed Jun 14, 2024
1 parent 9df56c6 commit d464f12
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 @@ -49,6 +49,6 @@ def sum(self, field_name: str):
def avg(self, field_name: str):
if not self.is_valid:
self.build_query()
query = f"SELECT AVG(mr.{field_name}) AS value FROM public.rooms_room as r INNER JOIN public.dashboard_roommetrics AS mr ON mr.room_id=r.uuid {self.join_clause} WHERE {self.where_clause};"
query = f"SELECT COALESCE(AVG(mr.{field_name}), 0) AS value FROM public.rooms_room as r INNER JOIN public.dashboard_roommetrics AS mr ON mr.room_id=r.uuid {self.join_clause} WHERE {self.where_clause};"

return query, self.params

0 comments on commit d464f12

Please sign in to comment.