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
4680be77
Commit
4680be77
authored
Mar 31, 2021
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move min max methods to utils usage_data.rb
Add specs for nil methods
parent
f0e7574b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
48 deletions
+92
-48
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+0
-48
lib/gitlab/usage_data_queries.rb
lib/gitlab/usage_data_queries.rb
+24
-0
lib/gitlab/utils/usage_data.rb
lib/gitlab/utils/usage_data.rb
+48
-0
spec/lib/gitlab/usage_data_queries_spec.rb
spec/lib/gitlab/usage_data_queries_spec.rb
+20
-0
No files found.
lib/gitlab/usage_data.rb
View file @
4680be77
...
...
@@ -839,54 +839,6 @@ module Gitlab
count
(
::
Issue
.
with_prometheus_alert_events
,
start:
issue_minimum_id
,
finish:
issue_maximum_id
)
end
def
user_minimum_id
strong_memoize
(
:user_minimum_id
)
do
::
User
.
minimum
(
:id
)
end
end
def
user_maximum_id
strong_memoize
(
:user_maximum_id
)
do
::
User
.
maximum
(
:id
)
end
end
def
issue_minimum_id
strong_memoize
(
:issue_minimum_id
)
do
::
Issue
.
minimum
(
:id
)
end
end
def
issue_maximum_id
strong_memoize
(
:issue_maximum_id
)
do
::
Issue
.
maximum
(
:id
)
end
end
def
deployment_minimum_id
strong_memoize
(
:deployment_minimum_id
)
do
::
Deployment
.
minimum
(
:id
)
end
end
def
deployment_maximum_id
strong_memoize
(
:deployment_maximum_id
)
do
::
Deployment
.
maximum
(
:id
)
end
end
def
project_minimum_id
strong_memoize
(
:project_minimum_id
)
do
::
Project
.
minimum
(
:id
)
end
end
def
project_maximum_id
strong_memoize
(
:project_maximum_id
)
do
::
Project
.
maximum
(
:id
)
end
end
def
self_monitoring_project
Gitlab
::
CurrentSettings
.
self_monitoring_project
end
...
...
lib/gitlab/usage_data_queries.rb
View file @
4680be77
...
...
@@ -36,6 +36,30 @@ module Gitlab
'SELECT '
+
args
.
map
{
|
arg
|
"(
#{
arg
}
)"
}.
join
(
' + '
)
end
def
user_minimum_id
end
def
user_maximum_id
end
def
issue_maximum_id
end
def
issue_minimum_id
end
def
deployment_minimum_id
end
def
deployment_maximum_id
end
def
project_minimum_id
end
def
project_maximum_id
end
private
def
raw_sql
(
relation
,
column
,
distinct
=
nil
)
...
...
lib/gitlab/utils/usage_data.rb
View file @
4680be77
...
...
@@ -209,6 +209,54 @@ module Gitlab
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
track_event
(
event_name
.
to_s
,
values:
values
)
end
def
user_minimum_id
strong_memoize
(
:user_minimum_id
)
do
::
User
.
minimum
(
:id
)
end
end
def
user_maximum_id
strong_memoize
(
:user_maximum_id
)
do
::
User
.
maximum
(
:id
)
end
end
def
issue_maximum_id
strong_memoize
(
:issue_maximum_id
)
do
::
Issue
.
maximum
(
:id
)
end
end
def
issue_minimum_id
strong_memoize
(
:issue_minimum_id
)
do
::
Issue
.
minimum
(
:id
)
end
end
def
deployment_minimum_id
strong_memoize
(
:deployment_minimum_id
)
do
::
Deployment
.
minimum
(
:id
)
end
end
def
deployment_maximum_id
strong_memoize
(
:deployment_maximum_id
)
do
::
Deployment
.
maximum
(
:id
)
end
end
def
project_minimum_id
strong_memoize
(
:project_minimum_id
)
do
::
Project
.
minimum
(
:id
)
end
end
def
project_maximum_id
strong_memoize
(
:project_maximum_id
)
do
::
Project
.
maximum
(
:id
)
end
end
private
def
prometheus_client
(
verify
:)
...
...
spec/lib/gitlab/usage_data_queries_spec.rb
View file @
4680be77
...
...
@@ -58,4 +58,24 @@ RSpec.describe Gitlab::UsageDataQueries do
.
to
eq
(
'SELECT (SELECT COUNT("users"."id") FROM "users") + (SELECT COUNT("issues"."id") FROM "issues")'
)
end
end
describe
'min/max methods'
do
it
'returns nil'
do
# user min/max
expect
(
described_class
.
user_minimum_id
).
to
eq
(
nil
)
expect
(
described_class
.
user_maximum_id
).
to
eq
(
nil
)
# issue min/max
expect
(
described_class
.
issue_minimum_id
).
to
eq
(
nil
)
expect
(
described_class
.
issue_maximum_id
).
to
eq
(
nil
)
# deployment min/max
expect
(
described_class
.
deployment_minimum_id
).
to
eq
(
nil
)
expect
(
described_class
.
deployment_maximum_id
).
to
eq
(
nil
)
# project min/max
expect
(
described_class
.
project_minimum_id
).
to
eq
(
nil
)
expect
(
described_class
.
project_maximum_id
).
to
eq
(
nil
)
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