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
9abcaac1
Commit
9abcaac1
authored
Mar 11, 2020
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimizes issues_using_zoom_quick_actions query
By using batch count
parent
257aae9f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
1 deletion
+54
-1
app/models/zoom_meeting.rb
app/models/zoom_meeting.rb
+6
-0
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+1
-1
spec/models/zoom_meeting_spec.rb
spec/models/zoom_meeting_spec.rb
+47
-0
No files found.
app/models/zoom_meeting.rb
View file @
9abcaac1
...
...
@@ -23,4 +23,10 @@ class ZoomMeeting < ApplicationRecord
def
self
.
canonical_meeting_url
(
issue
)
canonical_meeting
(
issue
)
&
.
url
end
def
self
.
distinct_count_by
(
column
=
nil
,
fallback
=
-
1
)
distinct
.
count
(
column
)
rescue
ActiveRecord
::
StatementInvalid
fallback
end
end
lib/gitlab/usage_data.rb
View file @
9abcaac1
...
...
@@ -85,7 +85,7 @@ module Gitlab
issues:
count
(
Issue
),
issues_created_from_gitlab_error_tracking_ui:
count
(
SentryIssue
),
issues_with_associated_zoom_link:
count
(
ZoomMeeting
.
added_to_issue
),
issues_using_zoom_quick_actions:
count
(
ZoomMeeting
.
select
(
:issue_id
).
distinct
,
batch:
false
),
issues_using_zoom_quick_actions:
distinct_count
(
ZoomMeeting
,
:issue_id
),
issues_with_embedded_grafana_charts_approx:
::
Gitlab
::
GrafanaEmbedUsageData
.
issue_count
,
incident_issues:
count
(
::
Issue
.
authored
(
::
User
.
alert_bot
)),
keys:
count
(
Key
),
...
...
spec/models/zoom_meeting_spec.rb
View file @
9abcaac1
...
...
@@ -151,4 +151,51 @@ describe ZoomMeeting do
it_behaves_like
'can remove meetings'
end
end
describe
'.distinct_count_by'
do
let
(
:issue_1
)
{
create
(
:issue
)
}
let
(
:issue_2
)
{
create
(
:issue
)
}
context
'two meetings for the same issue'
do
before
do
create
(
:zoom_meeting
,
issue:
issue_1
)
create
(
:zoom_meeting
,
:removed_from_issue
,
issue:
issue_1
)
end
it
'returns a count of 1'
do
expect
(
described_class
.
distinct_count_by
(
:issue_id
)).
to
eq
(
1
)
end
context
'when given no colum to count'
do
it
'counts by :id and returns a count of 2'
do
expect
(
described_class
.
distinct_count_by
).
to
eq
(
2
)
end
end
end
context
'one meeting for each issue'
do
it
'returns a count of 2'
do
create
(
:zoom_meeting
,
issue:
issue_1
)
create
(
:zoom_meeting
,
issue:
issue_2
)
expect
(
described_class
.
distinct_count_by
(
:issue_id
)).
to
eq
(
2
)
end
end
context
'the count query times out'
do
before
do
allow_next_instance_of
(
ActiveRecord
::
Relation
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:count
).
and_raise
(
ActiveRecord
::
StatementInvalid
.
new
(
''
))
end
end
it
'does not raise an error'
do
expect
{
described_class
.
distinct_count_by
(
:issue_id
)
}.
not_to
raise_error
end
it
'returns -1'
do
expect
(
described_class
.
distinct_count_by
(
:issue_id
)).
to
eq
(
-
1
)
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