Skip to content
Snippets Groups Projects
Unverified Commit a184c860 authored by Claire's avatar Claire Committed by GitHub
Browse files

Fix retention rate computation (#16854)

parent ec6eee96
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ class Admin::Metrics::Retention ...@@ -29,7 +29,7 @@ class Admin::Metrics::Retention
INNER JOIN new_users on new_users.id = users.id INNER JOIN new_users on new_users.id = users.id
WHERE date_trunc($3, users.current_sign_in_at) >= axis.retention_period 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 retained_users
) )
FROM ( FROM (
...@@ -55,11 +55,11 @@ class Admin::Metrics::Retention ...@@ -55,11 +55,11 @@ class Admin::Metrics::Retention
arr << current_cohort arr << current_cohort
end end
value, percent = row['retention_value_and_percent'].delete('{}').split(',') value, rate = row['retention_value_and_rate'].delete('{}').split(',')
current_cohort.data << CohortData.new( current_cohort.data << CohortData.new(
date: row['retention_period'], date: row['retention_period'],
percent: percent.to_f, percent: rate.to_f,
value: value.to_s value: value.to_s
) )
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment