From 6e5dd4bed6040f9747655c4f2b57b78eb1b7ec42 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Tue, 22 Jul 2025 19:52:24 +0200 Subject: [PATCH] Update stats query --- app/queries/stats_query.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/queries/stats_query.rb b/app/queries/stats_query.rb index e3ef3503..ad7ef90d 100644 --- a/app/queries/stats_query.rb +++ b/app/queries/stats_query.rb @@ -6,12 +6,12 @@ class StatsQuery end def points_stats - result = user.tracked_points.connection.execute(<<~SQL.squish) - SELECT#{' '} - COUNT(*) as total, + result = Point.connection.execute(<<~SQL.squish) + SELECT + COUNT(id) as total, COUNT(reverse_geocoded_at) as geocoded, - COUNT(CASE WHEN geodata = '{}' THEN 1 END) as without_data - FROM points#{' '} + COUNT(CASE WHEN geodata = '{}'::jsonb THEN 1 END) as without_data + FROM points WHERE user_id = #{user.id} SQL