Commit 3b948457 authored by Sean McGivern's avatar Sean McGivern

Merge branch '18668-clean-up-cohorts' into 'master'

Resolve "Clean up Cohorts"

See merge request gitlab-org/gitlab!20779
parents 1ba281b0 50be986d
...@@ -38,7 +38,7 @@ class CohortsService ...@@ -38,7 +38,7 @@ class CohortsService
{ {
registration_month: registration_month, registration_month: registration_month,
activity_months: activity_months, activity_months: activity_months[1..-1],
total: activity_months.first[:total], total: activity_months.first[:total],
inactive: inactive inactive: inactive
} }
......
- number_of_data_columns = @cohorts[:months_included] - 1
.bs-callout.clearfix .bs-callout.clearfix
%p %p
User cohorts are shown for the last #{@cohorts[:months_included]} = s_("Cohorts|User cohorts are shown for the last %{months_included} months. Only users with activity are counted in the 'New users' column; inactive users are counted separately.") % { months_included: @cohorts[:months_included] }
months. Only users with activity are counted in the cohort total; inactive
users are counted separately.
= link_to icon('question-circle'), help_page_path('user/instance_statistics/user_cohorts', anchor: 'cohorts'), title: 'About this feature', target: '_blank' = link_to icon('question-circle'), help_page_path('user/instance_statistics/user_cohorts', anchor: 'cohorts'), title: 'About this feature', target: '_blank'
.table-holder .table-holder.d-xl-table
%table.table %table.table
%thead %thead
%tr %tr
%th Registration month %th.border-right.pt-4{ colspan: 3 }
%th Inactive users %th.font-weight-bold.pt-4{ colspan: number_of_data_columns }
%th Cohort total = s_("Cohorts|Returning users")
- @cohorts[:months_included].times do |i| %tr
%th Month #{i} %th.border-top-0
= s_("Cohorts|Registration month")
%th.border-top-0
= s_("Cohorts|Inactive users")
%th.border-top-0.border-right
= s_("Cohorts|New users")
- number_of_data_columns.times do |i|
%th.border-top-0
= s_("Cohorts|Month %{month_index}") % { month_index: i + 1 }
%tbody %tbody
- @cohorts[:cohorts].each do |cohort| - @cohorts[:cohorts].each do |cohort|
%tr %tr
%td= cohort[:registration_month] %td= cohort[:registration_month]
%td= cohort[:inactive] %td= cohort[:inactive]
%td= cohort[:total] %td.border-right= cohort[:total]
- cohort[:activity_months].each do |activity_month| - cohort[:activity_months].each do |activity_month|
%td %td
- next if cohort[:total] == '0' - next if cohort[:total] == '0'
......
---
title: Clean up the cohorts table
merge_request: 20779
author:
type: changed
...@@ -4340,6 +4340,24 @@ msgstr "" ...@@ -4340,6 +4340,24 @@ msgstr ""
msgid "Cohorts" msgid "Cohorts"
msgstr "" msgstr ""
msgid "Cohorts|Inactive users"
msgstr ""
msgid "Cohorts|Month %{month_index}"
msgstr ""
msgid "Cohorts|New users"
msgstr ""
msgid "Cohorts|Registration month"
msgstr ""
msgid "Cohorts|Returning users"
msgstr ""
msgid "Cohorts|User cohorts are shown for the last %{months_included} months. Only users with activity are counted in the 'New users' column; inactive users are counted separately."
msgstr ""
msgid "Collapse" msgid "Collapse"
msgstr "" msgstr ""
......
...@@ -22,73 +22,73 @@ describe CohortsService do ...@@ -22,73 +22,73 @@ describe CohortsService do
expected_cohorts = [ expected_cohorts = [
{ {
registration_month: month_start(11), registration_month: month_start(11),
activity_months: Array.new(12) { { total: 0, percentage: 0 } }, activity_months: Array.new(11) { { total: 0, percentage: 0 } },
total: 0, total: 0,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(10), registration_month: month_start(10),
activity_months: [{ total: 2, percentage: 100 }] + Array.new(10) { { total: 1, percentage: 50 } }, activity_months: Array.new(10) { { total: 1, percentage: 50 } },
total: 2, total: 2,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(9), registration_month: month_start(9),
activity_months: Array.new(10) { { total: 0, percentage: 0 } }, activity_months: Array.new(9) { { total: 0, percentage: 0 } },
total: 0, total: 0,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(8), registration_month: month_start(8),
activity_months: [{ total: 2, percentage: 100 }] + Array.new(8) { { total: 1, percentage: 50 } }, activity_months: Array.new(8) { { total: 1, percentage: 50 } },
total: 2, total: 2,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(7), registration_month: month_start(7),
activity_months: Array.new(8) { { total: 0, percentage: 0 } }, activity_months: Array.new(7) { { total: 0, percentage: 0 } },
total: 0, total: 0,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(6), registration_month: month_start(6),
activity_months: [{ total: 2, percentage: 100 }] + Array.new(6) { { total: 1, percentage: 50 } }, activity_months: Array.new(6) { { total: 1, percentage: 50 } },
total: 2, total: 2,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(5), registration_month: month_start(5),
activity_months: Array.new(6) { { total: 0, percentage: 0 } }, activity_months: Array.new(5) { { total: 0, percentage: 0 } },
total: 0, total: 0,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(4), registration_month: month_start(4),
activity_months: [{ total: 2, percentage: 100 }] + Array.new(4) { { total: 1, percentage: 50 } }, activity_months: Array.new(4) { { total: 1, percentage: 50 } },
total: 2, total: 2,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(3), registration_month: month_start(3),
activity_months: Array.new(4) { { total: 0, percentage: 0 } }, activity_months: Array.new(3) { { total: 0, percentage: 0 } },
total: 0, total: 0,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(2), registration_month: month_start(2),
activity_months: [{ total: 2, percentage: 100 }] + Array.new(2) { { total: 1, percentage: 50 } }, activity_months: Array.new(2) { { total: 1, percentage: 50 } },
total: 2, total: 2,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(1), registration_month: month_start(1),
activity_months: Array.new(2) { { total: 0, percentage: 0 } }, activity_months: Array.new(1) { { total: 0, percentage: 0 } },
total: 0, total: 0,
inactive: 0 inactive: 0
}, },
{ {
registration_month: month_start(0), registration_month: month_start(0),
activity_months: [{ total: 2, percentage: 100 }], activity_months: [],
total: 2, total: 2,
inactive: 1 inactive: 1
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment