summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-04-07 19:54:06 +0100
committerRémy Coutable <remy@rymai.me>2017-04-14 15:20:55 +0200
commitf17f60405eb5ae9b0091abf566b332ff08267145 (patch)
treea96b56eeeb091d54808c804ca48182d96bd93229
parenta67b6b38948df3b4028d343e87f87558b66fdbf6 (diff)
downloadgitlab-ce-f17f60405eb5ae9b0091abf566b332ff08267145.tar.gz
Use last_activity_on in cohorts
-rw-r--r--app/services/cohorts_service.rb12
-rw-r--r--spec/services/cohorts_service_spec.rb4
2 files changed, 8 insertions, 8 deletions
diff --git a/app/services/cohorts_service.rb b/app/services/cohorts_service.rb
index a7963f01176..6781533af28 100644
--- a/app/services/cohorts_service.rb
+++ b/app/services/cohorts_service.rb
@@ -68,24 +68,24 @@ class CohortsService
# Get a hash that looks like:
#
# {
- # [created_at_month, current_sign_in_at_month] => count,
- # [created_at_month, current_sign_in_at_month_2] => count_2,
+ # [created_at_month, last_activity_on_month] => count,
+ # [created_at_month, last_activity_on_month_2] => count_2,
# # etc.
# }
#
- # created_at_month can never be nil, but current_sign_in_at_month can (when a
+ # created_at_month can never be nil, but last_activity_on_month can (when a
# user has never logged in, just been created). This covers the last
# MONTHS_INCLUDED months.
def counts_by_month
@counts_by_month ||=
begin
created_at_month = column_to_date('created_at')
- current_sign_in_at_month = column_to_date('current_sign_in_at')
+ last_activity_on_month = column_to_date('last_activity_on')
User
.where('created_at > ?', MONTHS_INCLUDED.months.ago.end_of_month)
- .group(created_at_month, current_sign_in_at_month)
- .reorder("#{created_at_month} ASC", "#{current_sign_in_at_month} ASC")
+ .group(created_at_month, last_activity_on_month)
+ .reorder("#{created_at_month} ASC", "#{last_activity_on_month} ASC")
.count
end
end
diff --git a/spec/services/cohorts_service_spec.rb b/spec/services/cohorts_service_spec.rb
index 5dd89e3e341..1e99442fdcb 100644
--- a/spec/services/cohorts_service_spec.rb
+++ b/spec/services/cohorts_service_spec.rb
@@ -11,8 +11,8 @@ describe CohortsService do
6.times do |months_ago|
months_ago_time = (months_ago * 2).months.ago
- create(:user, created_at: months_ago_time, current_sign_in_at: Time.now)
- create(:user, created_at: months_ago_time, current_sign_in_at: months_ago_time)
+ create(:user, created_at: months_ago_time, last_activity_on: Time.now)
+ create(:user, created_at: months_ago_time, last_activity_on: months_ago_time)
end
create(:user) # this user is inactive and belongs to the current month