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
864d99ad
Commit
864d99ad
authored
Feb 11, 2022
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only log inefficient query error
Rather than sending a lot of exceptions to Sentry
parent
3312e2b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
app/finders/deployments_finder.rb
app/finders/deployments_finder.rb
+9
-3
spec/finders/deployments_finder_spec.rb
spec/finders/deployments_finder_spec.rb
+1
-5
No files found.
app/finders/deployments_finder.rb
View file @
864d99ad
...
...
@@ -49,6 +49,10 @@ class DeploymentsFinder
private
def
raise_for_inefficient_updated_at_query?
params
.
fetch
(
:raise_for_inefficient_updated_at_query
,
Rails
.
env
.
development?
||
Rails
.
env
.
test?
)
end
def
validate!
if
filter_by_updated_at?
&&
filter_by_finished_at?
raise
InefficientQueryError
,
'Both `updated_at` filter and `finished_at` filter can not be specified'
...
...
@@ -57,9 +61,11 @@ class DeploymentsFinder
# Currently, the inefficient parameters are allowed in order to avoid breaking changes in Deployment API.
# We'll switch to a hard error in https://gitlab.com/gitlab-org/gitlab/-/issues/328500.
if
(
filter_by_updated_at?
&&
!
order_by_updated_at?
)
||
(
!
filter_by_updated_at?
&&
order_by_updated_at?
)
Gitlab
::
ErrorTracking
.
track_and_raise_for_dev_exception
(
InefficientQueryError
.
new
(
'`updated_at` filter and `updated_at` sorting must be paired'
)
)
error
=
InefficientQueryError
.
new
(
'`updated_at` filter and `updated_at` sorting must be paired'
)
Gitlab
::
ErrorTracking
.
log_exception
(
error
)
raise
error
if
raise_for_inefficient_updated_at_query?
end
if
(
filter_by_finished_at?
&&
!
order_by_finished_at?
)
||
(
!
filter_by_finished_at?
&&
order_by_finished_at?
)
...
...
spec/finders/deployments_finder_spec.rb
View file @
864d99ad
...
...
@@ -222,11 +222,7 @@ RSpec.describe DeploymentsFinder do
end
describe
'enforce sorting to `updated_at` sorting'
do
let
(
:params
)
{
{
**
base_params
,
updated_before:
1
.
day
.
ago
,
order_by:
'id'
,
sort:
'asc'
}
}
before
do
allow
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_and_raise_for_dev_exception
)
end
let
(
:params
)
{
{
**
base_params
,
updated_before:
1
.
day
.
ago
,
order_by:
'id'
,
sort:
'asc'
,
raise_for_inefficient_updated_at_query:
false
}
}
it
'sorts by only one column'
do
expect
(
subject
.
order_values
.
size
).
to
eq
(
2
)
...
...
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