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
27d75b30
Commit
27d75b30
authored
Jun 19, 2020
by
Alper Akgun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rolling 28 day time period counters for snippets
Also adds the "counts_monthly" section to the usage ping
parent
04f6bd8e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
9 deletions
+46
-9
changelogs/unreleased/221184-rolling-28-day-time-period-for-all-usage-ping-counters.yml
...olling-28-day-time-period-for-all-usage-ping-counters.yml
+5
-0
ee/spec/lib/ee/gitlab/usage_data_spec.rb
ee/spec/lib/ee/gitlab/usage_data_spec.rb
+0
-8
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+10
-1
spec/factories/usage_data.rb
spec/factories/usage_data.rb
+5
-0
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+18
-0
spec/support/helpers/usage_data_helpers.rb
spec/support/helpers/usage_data_helpers.rb
+8
-0
No files found.
changelogs/unreleased/221184-rolling-28-day-time-period-for-all-usage-ping-counters.yml
0 → 100644
View file @
27d75b30
---
title
:
Rolling 28 day time period counters for snippets
merge_request
:
34363
author
:
type
:
added
ee/spec/lib/ee/gitlab/usage_data_spec.rb
View file @
27d75b30
...
...
@@ -724,12 +724,4 @@ RSpec.describe Gitlab::UsageData do
end
end
end
def
for_defined_days_back
(
days:
[
29
,
2
])
days
.
each
do
|
n
|
Timecop
.
travel
(
n
.
days
.
ago
)
do
yield
end
end
end
end
lib/gitlab/usage_data.rb
View file @
27d75b30
...
...
@@ -32,6 +32,7 @@ module Gitlab
with_finished_at
(
:recording_ce_finished_at
)
do
license_usage_data
.
merge
(
system_usage_data
)
.
merge
(
system_usage_data_monthly
)
.
merge
(
features_usage_data
)
.
merge
(
components_usage_data
)
.
merge
(
cycle_analytics_usage_data
)
...
...
@@ -161,9 +162,17 @@ module Gitlab
)
}
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable Metrics/AbcSize
def
system_usage_data_monthly
{
counts_monthly:
{
snippets:
count
(
Snippet
.
where
(
default_time_period
))
}
}
end
# rubocop: enable CodeReuse/ActiveRecord
def
cycle_analytics_usage_data
Gitlab
::
CycleAnalytics
::
UsageData
.
new
.
to_json
rescue
ActiveRecord
::
StatementInvalid
...
...
spec/factories/usage_data.rb
View file @
27d75b30
...
...
@@ -89,6 +89,11 @@ FactoryBot.define do
create
(
:grafana_integration
,
project:
projects
[
2
],
enabled:
false
)
ProjectFeature
.
first
.
update_attribute
(
'repository_access_level'
,
0
)
# Create fresh & a month (28-days SMAU) old data
[
2
,
29
].
each
do
|
n
|
create
(
:snippet
,
created_at:
n
.
days
.
ago
)
end
end
end
end
spec/lib/gitlab/usage_data_spec.rb
View file @
27d75b30
...
...
@@ -44,6 +44,10 @@ describe Gitlab::UsageData, :aggregate_failures do
expect
(
UsageDataHelpers
::
COUNTS_KEYS
-
count_data
.
keys
).
to
be_empty
end
it
'gathers usage counts monthly hash'
do
expect
(
subject
[
:counts_monthly
]).
to
be_an
(
Hash
)
end
it
'gathers projects data correctly'
do
count_data
=
subject
[
:counts
]
...
...
@@ -103,6 +107,8 @@ describe Gitlab::UsageData, :aggregate_failures do
expect
(
count_data
[
:grafana_integrated_projects
]).
to
eq
(
2
)
expect
(
count_data
[
:clusters_applications_jupyter
]).
to
eq
(
1
)
expect
(
count_data
[
:clusters_management_project
]).
to
eq
(
1
)
expect
(
count_data
[
:snippets
]).
to
eq
(
2
)
end
it
'gathers object store usage correctly'
do
...
...
@@ -181,6 +187,18 @@ describe Gitlab::UsageData, :aggregate_failures do
end
end
describe
'.system_usage_data_monthly'
do
let!
(
:ud
)
{
build
(
:usage_data
)
}
subject
{
described_class
.
system_usage_data_monthly
}
it
'gathers projects data correctly'
do
counts_monthly
=
subject
[
:counts_monthly
]
expect
(
counts_monthly
[
:snippets
]).
to
eq
(
1
)
end
end
describe
'#usage_data_counters'
do
subject
{
described_class
.
usage_data_counters
}
...
...
spec/support/helpers/usage_data_helpers.rb
View file @
27d75b30
...
...
@@ -233,4 +233,12 @@ module UsageDataHelpers
allow
(
client
).
to
receive
(
:aggregate
).
and_return
({})
end
end
def
for_defined_days_back
(
days:
[
29
,
2
])
days
.
each
do
|
n
|
Timecop
.
travel
(
n
.
days
.
ago
)
do
yield
end
end
end
end
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