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
e87a67e2
Commit
e87a67e2
authored
Dec 22, 2020
by
Alina Mihaila
Committed by
Mikołaj Wawrzyniak
Dec 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add estimate_batch_distinct_count changes to dangerbot database
parent
2a54e01b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
26 deletions
+16
-26
doc/development/database_review.md
doc/development/database_review.md
+1
-1
lib/gitlab/danger/helper.rb
lib/gitlab/danger/helper.rb
+1
-1
spec/lib/gitlab/danger/helper_spec.rb
spec/lib/gitlab/danger/helper_spec.rb
+14
-24
No files found.
doc/development/database_review.md
View file @
e87a67e2
...
...
@@ -25,7 +25,7 @@ A database review is required for:
generally up to the author of a merge request to decide whether or
not complex queries are being introduced and if they require a
database review.
-
Changes in usage data metrics that use
`count`
and
`
distinct_count`
.
-
Changes in usage data metrics that use
`count`
,
`distinct_count`
and
`estimate_batch_
distinct_count`
.
These metrics could have complex queries over large tables.
See the
[
Product Analytics Guide
](
https://about.gitlab.com/handbook/product/product-analytics-guide/
)
for implementation details.
...
...
lib/gitlab/danger/helper.rb
View file @
e87a67e2
...
...
@@ -128,7 +128,7 @@ module Gitlab
}.
freeze
# First-match win, so be sure to put more specific regex at the top...
CATEGORIES
=
{
[
%r{usage_data
\.
rb}
,
%r{^(
\+
|-).*
(count|
distinct_count)
\(
.*
\)
(.*)$}
]
=>
[
:database
,
:backend
],
[
%r{usage_data
\.
rb}
,
%r{^(
\+
|-).*
\s
+(count|distinct_count|estimate_batch_
distinct_count)
\(
.*
\)
(.*)$}
]
=>
[
:database
,
:backend
],
%r{
\A
doc/.*(
\.
(md|png|gif|jpg))
\z
}
=>
:docs
,
%r{
\A
(CONTRIBUTING|LICENSE|MAINTENANCE|PHILOSOPHY|PROCESS|README)(
\.
md)?
\z
}
=>
:docs
,
...
...
spec/lib/gitlab/danger/helper_spec.rb
View file @
e87a67e2
...
...
@@ -351,33 +351,23 @@ RSpec.describe Gitlab::Danger::Helper do
end
context
'having specific changes'
do
it
'has database and backend categories'
do
changed_files
=
[
'usage_data.rb'
,
'lib/gitlab/usage_data.rb'
,
'ee/lib/ee/gitlab/usage_data.rb'
]
changed_files
.
each
do
|
file
|
allow
(
fake_git
).
to
receive
(
:diff_for_file
).
with
(
file
)
{
double
(
:diff
,
patch:
"+ count(User.active)"
)
}
expect
(
helper
.
categories_for_file
(
file
)).
to
eq
([
:database
,
:backend
])
end
end
it
'has backend category'
do
allow
(
fake_git
).
to
receive
(
:diff_for_file
).
with
(
'usage_data.rb'
)
{
double
(
:diff
,
patch:
"+ alt_usage_data(User.active)"
)
}
expect
(
helper
.
categories_for_file
(
'usage_data.rb'
)).
to
eq
([
:backend
])
where
(
:expected_categories
,
:patch
,
:changed_files
)
do
[
:database
,
:backend
]
|
'+ count(User.active)'
|
[
'usage_data.rb'
,
'lib/gitlab/usage_data.rb'
,
'ee/lib/ee/gitlab/usage_data.rb'
]
[
:database
,
:backend
]
|
'+ estimate_batch_distinct_count(User.active)'
|
[
'usage_data.rb'
]
[
:backend
]
|
'+ alt_usage_data(User.active)'
|
[
'usage_data.rb'
]
[
:backend
]
|
'+ count(User.active)'
|
[
'user.rb'
]
[
:backend
]
|
'+ count(User.active)'
|
[
'usage_data/topology.rb'
]
[
:backend
]
|
'+ foo_count(User.active)'
|
[
'usage_data.rb'
]
end
it
'has backend category for changes outside usage_data files'
do
allow
(
fake_git
).
to
receive
(
:diff_for_file
).
with
(
'user.rb'
)
{
double
(
:diff
,
patch:
"+ count(User.active)"
)
}
expect
(
helper
.
categories_for_file
(
'user.rb'
)).
to
eq
([
:backend
])
end
with_them
do
it
'has the correct categories'
do
changed_files
.
each
do
|
file
|
allow
(
fake_git
).
to
receive
(
:diff_for_file
).
with
(
file
)
{
double
(
:diff
,
patch:
patch
)
}
it
'has backend category for files that are not usage_data.rb'
do
changed_file
=
'usage_data/topology.rb'
allow
(
fake_git
).
to
receive
(
:diff_for_file
).
with
(
changed_file
)
{
double
(
:diff
,
patch:
"+ count(User.active)"
)
}
expect
(
helper
.
categories_for_file
(
changed_file
)).
to
eq
([
:backend
])
expect
(
helper
.
categories_for_file
(
file
)).
to
eq
(
expected_categories
)
end
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