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
3f31da9c
Commit
3f31da9c
authored
Feb 13, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restrict cycle analytics usage data to instances that use postgres only
parent
41bb23ae
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
10 deletions
+9
-10
app/models/cycle_analytics.rb
app/models/cycle_analytics.rb
+2
-7
lib/gitlab/cycle_analytics/base_query.rb
lib/gitlab/cycle_analytics/base_query.rb
+2
-2
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+3
-0
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+1
-0
spec/support/cycle_analytics_helpers/test_generation.rb
spec/support/cycle_analytics_helpers/test_generation.rb
+1
-1
No files found.
app/models/cycle_analytics.rb
View file @
3f31da9c
...
@@ -7,13 +7,8 @@ class CycleAnalytics
...
@@ -7,13 +7,8 @@ class CycleAnalytics
end
end
def
all_medians_per_stage
def
all_medians_per_stage
medians_per_stage
=
{}
STAGES
.
each_with_object
({})
do
|
stage_name
,
hsh
|
hsh
[
stage_name
]
=
self
[
stage_name
].
median
# We only need this data for Postgres instances
return
medians_per_stage
if
Gitlab
::
Database
.
mysql?
STAGES
.
each
do
|
stage_name
|
medians_per_stage
[
stage_name
]
=
self
[
stage_name
].
median
end
end
end
end
...
...
lib/gitlab/cycle_analytics/base_query.rb
View file @
3f31da9c
...
@@ -8,14 +8,14 @@ module Gitlab
...
@@ -8,14 +8,14 @@ module Gitlab
private
private
def
base_query
def
base_query
@base_query
||=
stage_query
([
@project
.
id
])
@base_query
||=
stage_query
([
@project
.
id
])
# rubocop:disable Gitlab/ModuleWithInstanceVariables
end
end
def
stage_query
(
project_ids
)
def
stage_query
(
project_ids
)
query
=
mr_closing_issues_table
.
join
(
issue_table
).
on
(
issue_table
[
:id
].
eq
(
mr_closing_issues_table
[
:issue_id
]))
query
=
mr_closing_issues_table
.
join
(
issue_table
).
on
(
issue_table
[
:id
].
eq
(
mr_closing_issues_table
[
:issue_id
]))
.
join
(
issue_metrics_table
).
on
(
issue_table
[
:id
].
eq
(
issue_metrics_table
[
:issue_id
]))
.
join
(
issue_metrics_table
).
on
(
issue_table
[
:id
].
eq
(
issue_metrics_table
[
:issue_id
]))
.
project
(
issue_table
[
:project_id
].
as
(
"project_id"
))
.
project
(
issue_table
[
:project_id
].
as
(
"project_id"
))
.
where
(
issue_table
[
:project_id
].
in
(
project_ids
))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
.
where
(
issue_table
[
:project_id
].
in
(
project_ids
))
.
where
(
issue_table
[
:created_at
].
gteq
(
@options
[
:from
]))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
.
where
(
issue_table
[
:created_at
].
gteq
(
@options
[
:from
]))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
# Load merge_requests
# Load merge_requests
...
...
lib/gitlab/usage_data.rb
View file @
3f31da9c
...
@@ -73,6 +73,9 @@ module Gitlab
...
@@ -73,6 +73,9 @@ module Gitlab
end
end
def
cycle_analytics_usage_data
def
cycle_analytics_usage_data
# We only want to generate this data for instances that use PostgreSQL
return
{}
if
Gitlab
::
Database
.
mysql?
projects
=
Project
.
sorted_by_activity
.
limit
(
Gitlab
::
CycleAnalytics
::
UsageData
::
PROJECTS_LIMIT
)
projects
=
Project
.
sorted_by_activity
.
limit
(
Gitlab
::
CycleAnalytics
::
UsageData
::
PROJECTS_LIMIT
)
Gitlab
::
CycleAnalytics
::
UsageData
.
new
(
projects
,
{
from:
7
.
days
.
ago
}).
to_json
Gitlab
::
CycleAnalytics
::
UsageData
.
new
(
projects
,
{
from:
7
.
days
.
ago
}).
to_json
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
3f31da9c
...
@@ -36,6 +36,7 @@ describe Gitlab::UsageData do
...
@@ -36,6 +36,7 @@ describe Gitlab::UsageData do
gitlab_shared_runners
gitlab_shared_runners
git
git
database
database
avg_cycle_analytics
)
)
)
)
end
end
...
...
spec/support/cycle_analytics_helpers/test_generation.rb
View file @
3f31da9c
...
@@ -50,7 +50,7 @@ module CycleAnalyticsHelpers
...
@@ -50,7 +50,7 @@ module CycleAnalyticsHelpers
end
end
median_time_difference
=
time_differences
.
sort
[
2
]
median_time_difference
=
time_differences
.
sort
[
2
]
expect
(
subject
[
phase
].
median
).
to
be_within
(
5
).
of
(
median_time_difference
)
expect
(
subject
[
phase
].
median
.
presence
).
to
be_within
(
5
).
of
(
median_time_difference
)
end
end
context
"when the data belongs to another project"
do
context
"when the data belongs to another project"
do
...
...
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