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
0c1a5d1f
Commit
0c1a5d1f
authored
Nov 23, 2020
by
ggelatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor pkg event name handling
Move testing for guest events out of the events class.
parent
cfc4e738
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
app/models/packages/event.rb
app/models/packages/event.rb
+2
-3
app/services/packages/create_event_service.rb
app/services/packages/create_event_service.rb
+7
-1
No files found.
app/models/packages/event.rb
View file @
0c1a5d1f
...
...
@@ -25,7 +25,7 @@ class Packages::Event < ApplicationRecord
enum
originator_type:
{
user:
0
,
deploy_token:
1
,
guest:
2
}
def
self
.
allowed_event_name
(
event_scope
,
event_type
,
originator
)
return
unless
event_allowed?
(
event_
scope
,
event_type
,
originator
)
return
unless
event_allowed?
(
event_
type
)
# remove `package` from the event name to avoid issues with HLLRedisCounter class parsing
"i_package_
#{
event_scope
}
_
#{
originator
}
_
#{
event_type
.
gsub
(
/_packages?/
,
""
)
}
"
...
...
@@ -33,8 +33,7 @@ class Packages::Event < ApplicationRecord
# Remove some of the events, for now, so we don't hammer Redis too hard.
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/280770
def
self
.
event_allowed?
(
event_scope
,
event_type
,
originator
)
return
false
if
originator
.
to_sym
==
:guest
def
self
.
event_allowed?
(
event_type
)
return
true
if
UNIQUE_EVENTS_ALLOWED
.
include?
(
event_type
.
to_sym
)
false
...
...
app/services/packages/create_event_service.rb
View file @
0c1a5d1f
...
...
@@ -4,8 +4,10 @@ module Packages
class
CreateEventService
<
BaseService
def
execute
if
Feature
.
enabled?
(
:collect_package_events_redis
)
&&
redis_event_name
unless
guest?
::
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
track_event
(
current_user
.
id
,
redis_event_name
)
end
end
if
Feature
.
enabled?
(
:collect_package_events
)
&&
Gitlab
::
Database
.
read_write?
::
Packages
::
Event
.
create!
(
...
...
@@ -45,5 +47,9 @@ module Packages
:guest
end
end
def
guest?
originator_type
==
:guest
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