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
671dba00
Commit
671dba00
authored
Jul 10, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add events counter cop
parent
63f1c564
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
+35
-6
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+1
-6
rubocop/cop/usage_data/event_counters.rb
rubocop/cop/usage_data/event_counters.rb
+34
-0
No files found.
lib/gitlab/usage_data.rb
View file @
671dba00
...
...
@@ -406,13 +406,8 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def
merge_requests_users
(
time_period
)
query
=
Event
.
where
(
target_type:
Event
::
TARGET_TYPES
[
:merge_request
].
to_s
)
.
where
(
time_period
)
distinct_count
(
query
,
Event
.
where
(
target_type:
Event
::
TARGET_TYPES
[
:merge_request
].
to_s
).
where
(
time_period
)
,
:author_id
,
start:
user_minimum_id
,
finish:
user_maximum_id
...
...
rubocop/cop/usage_data/event_counters.rb
0 → 100644
View file @
671dba00
# frozen_string_literal: true
module
RuboCop
module
Cop
module
Gitlab
class
EventCounters
<
RuboCop
::
Cop
::
Cop
MSG
=
'Use the `count` or `distinct_count`'
def_node_matcher
:events_table
,
<<~
PATTERN
$(send (const {nil cbase} :Event ) ...)
PATTERN
def
on_send
(
node
)
return
unless
usage_data_files?
(
node
)
matched_node
=
events_table
(
node
)
return
if
matched_node
.
nil?
method_name
=
matched_node
.
parent
.
children
[
1
]
add_offense
(
node
,
location: :expression
)
unless
[
:count
,
:distinct_count
].
include?
(
method_name
)
end
private
def
usage_data_files?
(
node
)
path
=
node
.
location
.
expression
.
source_buffer
.
name
path
.
include?
(
'usage_data.rb'
)
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