about summary refs log tree commit diff
path: root/app/lib/admin
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-10-14 22:20:37 +0200
committerGitHub <noreply@github.com>2021-10-14 22:20:37 +0200
commita184c860ca90dec6a8db99d3d767e9786ae149c4 (patch)
tree26ea62cc0eb002454a9f52861d9a842b2077e14f /app/lib/admin
parentec6eee96d0b398a99ba0abb9c1cf30c02729e52e (diff)
Fix retention rate computation (#16854)
Diffstat (limited to 'app/lib/admin')
-rw-r--r--app/lib/admin/metrics/retention.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/lib/admin/metrics/retention.rb b/app/lib/admin/metrics/retention.rb
index 49ab89129..6b9dfde49 100644
--- a/app/lib/admin/metrics/retention.rb
+++ b/app/lib/admin/metrics/retention.rb
@@ -29,7 +29,7 @@ class Admin::Metrics::Retention
           INNER JOIN new_users on new_users.id = users.id
           WHERE date_trunc($3, users.current_sign_in_at) >= axis.retention_period
         )
-        SELECT ARRAY[count(*), (count(*) + 1)::float / (SELECT count(*) + 1 FROM new_users)] AS retention_value_and_percent
+        SELECT ARRAY[count(*), (count(*))::float / (SELECT GREATEST(count(*), 1) FROM new_users)] AS retention_value_and_rate
         FROM retained_users
       )
       FROM (
@@ -55,11 +55,11 @@ class Admin::Metrics::Retention
         arr << current_cohort
       end
 
-      value, percent = row['retention_value_and_percent'].delete('{}').split(',')
+      value, rate = row['retention_value_and_rate'].delete('{}').split(',')
 
       current_cohort.data << CohortData.new(
         date: row['retention_period'],
-        percent: percent.to_f,
+        percent: rate.to_f,
         value: value.to_s
       )
     end