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
84f57b1e
Commit
84f57b1e
authored
Mar 27, 2020
by
Alper Akgun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Harden jira_usage counters
Return -1 for fallback, and 0 when no data exists
parent
9a9ef1cd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
6 deletions
+16
-6
changelogs/unreleased/212398-harden-optimie-jira-usage-data.yml
...logs/unreleased/212398-harden-optimie-jira-usage-data.yml
+5
-0
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+4
-6
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+7
-0
No files found.
changelogs/unreleased/212398-harden-optimie-jira-usage-data.yml
0 → 100644
View file @
84f57b1e
---
title
:
Harden jira usage data
merge_request
:
27973
author
:
type
:
performance
lib/gitlab/usage_data.rb
View file @
84f57b1e
...
@@ -202,7 +202,7 @@ module Gitlab
...
@@ -202,7 +202,7 @@ module Gitlab
results
=
{
results
=
{
projects_jira_server_active:
0
,
projects_jira_server_active:
0
,
projects_jira_cloud_active:
0
,
projects_jira_cloud_active:
0
,
projects_jira_active:
-
1
projects_jira_active:
0
}
}
Service
.
active
Service
.
active
...
@@ -217,14 +217,12 @@ module Gitlab
...
@@ -217,14 +217,12 @@ module Gitlab
results
[
:projects_jira_server_active
]
+=
counts
[
:server
].
count
if
counts
[
:server
]
results
[
:projects_jira_server_active
]
+=
counts
[
:server
].
count
if
counts
[
:server
]
results
[
:projects_jira_cloud_active
]
+=
counts
[
:cloud
].
count
if
counts
[
:cloud
]
results
[
:projects_jira_cloud_active
]
+=
counts
[
:cloud
].
count
if
counts
[
:cloud
]
if
results
[
:projects_jira_active
]
==
-
1
results
[
:projects_jira_active
]
=
services
.
size
else
results
[
:projects_jira_active
]
+=
services
.
size
results
[
:projects_jira_active
]
+=
services
.
size
end
end
end
results
results
rescue
ActiveRecord
::
StatementInvalid
{
projects_jira_server_active:
-
1
,
projects_jira_cloud_active:
-
1
,
projects_jira_active:
-
1
}
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
84f57b1e
...
@@ -85,6 +85,13 @@ describe Gitlab::UsageData, :aggregate_failures do
...
@@ -85,6 +85,13 @@ describe Gitlab::UsageData, :aggregate_failures do
expect
{
subject
}.
not_to
raise_error
expect
{
subject
}.
not_to
raise_error
end
end
it
'jira usage works when queries time out'
do
allow_any_instance_of
(
ActiveRecord
::
Relation
)
.
to
receive
(
:find_in_batches
).
and_raise
(
ActiveRecord
::
StatementInvalid
.
new
(
''
))
expect
{
described_class
.
jira_usage
}.
not_to
raise_error
end
end
end
describe
'#usage_data_counters'
do
describe
'#usage_data_counters'
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