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
6c290834
Commit
6c290834
authored
Aug 28, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for events_for_category
parent
3d17057f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
lib/gitlab/usage_data_counters/hll_redis_counter.rb
lib/gitlab/usage_data_counters/hll_redis_counter.rb
+3
-1
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
.../lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+6
-0
No files found.
lib/gitlab/usage_data_counters/hll_redis_counter.rb
View file @
6c290834
...
@@ -53,8 +53,10 @@ module Gitlab
...
@@ -53,8 +53,10 @@ module Gitlab
Gitlab
::
Redis
::
HLL
.
count
(
keys:
keys
)
Gitlab
::
Redis
::
HLL
.
count
(
keys:
keys
)
end
end
# @param category [String] the category name
# @return [Array<String>] list of event names for given category
def
events_for_category
(
category
)
def
events_for_category
(
category
)
known_events
.
select
{
|
event
|
event
[
:category
]
==
category
}.
map
{
|
event
|
event
[
:name
]
}
known_events
.
select
{
|
event
|
event
[
:category
]
==
category
.
to_s
}.
map
{
|
event
|
event
[
:name
]
}
end
end
private
private
...
...
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
View file @
6c290834
...
@@ -43,6 +43,12 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
...
@@ -43,6 +43,12 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
Timecop
.
freeze
(
reference_time
)
{
example
.
run
}
Timecop
.
freeze
(
reference_time
)
{
example
.
run
}
end
end
describe
'.events_for_category'
do
it
'gets the event names for given category'
do
expect
(
described_class
.
events_for_category
(
:analytics
)).
to
contain_exactly
(
weekly_event
,
daily_event
)
end
end
describe
'.track_event'
do
describe
'.track_event'
do
it
"raise error if metrics don't have same aggregation"
do
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
)
expect
{
described_class
.
track_event
(
entity1
,
different_aggregation
,
Date
.
current
)
}
.
to
raise_error
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
::
UnknownAggregation
)
...
...
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