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
2e216dd4
Commit
2e216dd4
authored
Feb 21, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not count rails sql cache as queries in query limiting
parent
11bf575f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
lib/gitlab/query_limiting/active_support_subscriber.rb
lib/gitlab/query_limiting/active_support_subscriber.rb
+4
-2
spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb
...b/gitlab/query_limiting/active_support_subscriber_spec.rb
+23
-8
No files found.
lib/gitlab/query_limiting/active_support_subscriber.rb
View file @
2e216dd4
...
...
@@ -3,9 +3,11 @@ module Gitlab
class
ActiveSupportSubscriber
<
ActiveSupport
::
Subscriber
attach_to
:active_record
def
sql
(
*
)
def
sql
(
event
)
unless
event
.
payload
[
:name
]
==
'CACHE'
Transaction
.
current
&
.
increment
end
end
end
end
end
spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb
View file @
2e216dd4
require
'spec_helper'
describe
Gitlab
::
QueryLimiting
::
ActiveSupportSubscriber
do
describe
'#sql'
do
it
'increments the number of executed SQL queries'
do
transaction
=
double
(
:transaction
)
let
(
:transaction
)
{
instance_double
(
Gitlab
::
QueryLimiting
::
Transaction
,
increment:
true
)
}
before
do
allow
(
Gitlab
::
QueryLimiting
::
Transaction
)
.
to
receive
(
:current
)
.
and_return
(
transaction
)
end
describe
'#sql'
do
it
'increments the number of executed SQL queries'
do
User
.
count
expect
(
transaction
)
.
to
receive
(
:increment
)
.
at_least
(
:once
)
.
to
have_received
(
:increment
)
.
once
end
context
'when the query is actually a rails cache hit'
do
it
'does not increment the number of executed SQL queries'
do
ActiveRecord
::
Base
.
connection
.
cache
do
User
.
count
User
.
count
end
expect
(
transaction
)
.
to
have_received
(
:increment
)
.
once
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