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
13a462ab
Commit
13a462ab
authored
Oct 08, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert event name to string
parent
7a0c681b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
lib/gitlab/usage_data_counters/hll_redis_counter.rb
lib/gitlab/usage_data_counters/hll_redis_counter.rb
+2
-2
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
.../lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+10
-0
No files found.
lib/gitlab/usage_data_counters/hll_redis_counter.rb
View file @
13a462ab
...
...
@@ -44,7 +44,7 @@ module Gitlab
end
def
unique_events
(
event_names
:,
start_date
:,
end_date
:)
events
=
events_for
(
Array
(
event_names
))
events
=
events_for
(
Array
(
event_names
)
.
map
(
&
:to_s
)
)
raise
'Events should be in same slot'
unless
events_in_same_slot?
(
events
)
raise
'Events should be in same category'
unless
events_in_same_category?
(
events
)
...
...
@@ -141,7 +141,7 @@ module Gitlab
end
def
event_for
(
event_name
)
known_events
.
find
{
|
event
|
event
[
:name
]
==
event_name
}
known_events
.
find
{
|
event
|
event
[
:name
]
==
event_name
.
to_s
}
end
def
events_for
(
event_names
)
...
...
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
View file @
13a462ab
...
...
@@ -77,6 +77,12 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
stub_application_setting
(
usage_ping_enabled:
true
)
end
it
'tracks event when using symbol'
do
expect
(
Gitlab
::
Redis
::
HLL
).
to
receive
(
:add
)
described_class
.
track_event
(
entity1
,
:g_analytics_contribution
)
end
it
"raise error if metrics don't have same aggregation"
do
expect
{
described_class
.
track_event
(
entity1
,
different_aggregation
,
Date
.
current
)
}
.
to
raise_error
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
::
UnknownAggregation
)
end
...
...
@@ -201,6 +207,10 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
it
{
expect
(
described_class
.
unique_events
(
event_names:
weekly_event
,
start_date:
4
.
weeks
.
ago
,
end_date:
3
.
weeks
.
ago
)).
to
eq
(
1
)
}
end
context
'when using symbol as parameter'
do
it
{
expect
(
described_class
.
unique_events
(
event_names:
weekly_event
.
to_sym
,
start_date:
4
.
weeks
.
ago
,
end_date:
3
.
weeks
.
ago
)).
to
eq
(
1
)
}
end
context
'when using daily aggregation'
do
it
{
expect
(
described_class
.
unique_events
(
event_names:
daily_event
,
start_date:
7
.
days
.
ago
,
end_date:
Date
.
current
)).
to
eq
(
2
)
}
it
{
expect
(
described_class
.
unique_events
(
event_names:
daily_event
,
start_date:
28
.
days
.
ago
,
end_date:
Date
.
current
)).
to
eq
(
3
)
}
...
...
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