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
d4ea1e41
Commit
d4ea1e41
authored
Mar 02, 2020
by
Doug Stull
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize secure usage data counter
- group by causes timeouts in larger tables.
parent
b119a04f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+8
-7
No files found.
ee/lib/ee/gitlab/usage_data.rb
View file @
d4ea1e41
...
...
@@ -112,18 +112,19 @@ module EE
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
security_products_usage
results
=
count
(
::
Ci
::
Build
.
where
(
name:
SECURE_PRODUCT_TYPES
.
keys
).
group
(
:name
),
fallback:
Hash
.
new
(
-
1
),
batch:
false
)
results
=
SECURE_PRODUCT_TYPES
.
each_with_object
({})
do
|
(
secure_type
,
attribs
),
response
|
response
[
attribs
[
:name
]]
=
count
(
::
Ci
::
Build
.
where
(
name:
secure_type
),
fallback:
attribs
.
fetch
(
:fallback
,
-
1
))
# rubocop:disable CodeReuse/ActiveRecord
end
license_scan_count
=
results
.
delete
(
"license_scanning"
)
if
license_scan_count
&&
results
[
"license_management"
]
results
[
"license_management"
]
+=
license_scan_count
# handle license rename https://gitlab.com/gitlab-org/gitlab/issues/8911
license_scan_count
=
results
.
delete
(
:license_scanning_jobs
)
if
license_scan_count
&&
results
[
:license_management_jobs
]
results
[
:license_management_jobs
]
+=
license_scan_count
end
results
.
each_with_object
({})
{
|
(
key
,
value
),
response
|
response
[
SECURE_PRODUCT_TYPES
[
key
.
to_sym
][
:name
]]
=
value
}
results
end
# rubocop: enable CodeReuse/ActiveRecord
# Note: when adding a preference, check if it's mapped to an attribute of a User model. If so, name
# the base key part after a corresponding User model attribute, use its possible values as suffix values.
...
...
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