From 5ee3e2932f4da5caf5117cb138d6c17b6dcfa8bc Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Wed, 16 Nov 2022 22:11:09 -0500 Subject: [PATCH] FIX: Bug with admin trust level growth report (#19050) When this report in the admin dashboard has lots of data ( > 75 days of activity), the dates were ordered incorrectly. This is apparently expected behaviour; when using GROUP BY without specifying the ordering, PG decides to order, and it so happens that it works under some conditions but not others. Explicit ordering fixes the problem. However, because this works in some conditions but not others, we can't really add a useful test. --- app/models/concerns/reports/trust_level_growth.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/concerns/reports/trust_level_growth.rb b/app/models/concerns/reports/trust_level_growth.rb index 4171f947a54..0071b579ff1 100644 --- a/app/models/concerns/reports/trust_level_growth.rb +++ b/app/models/concerns/reports/trust_level_growth.rb @@ -39,6 +39,7 @@ module Reports::TrustLevelGrowth OR action = #{UserHistory.actions[:auto_trust_level_change]} ) GROUP BY date(created_at) + ORDER BY date(created_at) SQL data = Hash[ filters.collect { |x| [x, []] } ]