Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f17f6040
Commit
f17f6040
authored
Apr 07, 2017
by
Sean McGivern
Committed by
Rémy Coutable
Apr 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use last_activity_on in cohorts
parent
a67b6b38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
app/services/cohorts_service.rb
app/services/cohorts_service.rb
+6
-6
spec/services/cohorts_service_spec.rb
spec/services/cohorts_service_spec.rb
+2
-2
No files found.
app/services/cohorts_service.rb
View file @
f17f6040
...
...
@@ -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
...
...
spec/services/cohorts_service_spec.rb
View file @
f17f6040
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment