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
9572d85c
Commit
9572d85c
authored
Aug 19, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve method description, typo
parent
fba29932
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
13 deletions
+9
-13
lib/gitlab/analytics/unique_visits.rb
lib/gitlab/analytics/unique_visits.rb
+2
-2
lib/gitlab/usage_data_counters/hll_redis_counter.rb
lib/gitlab/usage_data_counters/hll_redis_counter.rb
+6
-10
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
.../lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+1
-1
No files found.
lib/gitlab/analytics/unique_visits.rb
View file @
9572d85c
...
...
@@ -10,8 +10,8 @@ module Gitlab
# Returns number of unique visitors for given targets in given time frame
#
# @param [String, Array[<String>]] targets ids of targets to count visits on. Special case for :any
# @param [ActiveSupport::TimeWithZone] start_
week
start of time frame
# @param [
Integer] weeks time frame length in weeks
# @param [ActiveSupport::TimeWithZone] start_
date
start of time frame
# @param [
ActiveSupport::TimeWithZone] end_date end of time frame
# @return [Integer] number of unique visitors
def
unique_visits_for
(
targets
:,
start_date:
7
.
days
.
ago
,
end_date:
start_date
+
1
.
week
)
target_ids
=
if
targets
==
:analytics
...
...
lib/gitlab/usage_data_counters/hll_redis_counter.rb
View file @
9572d85c
...
...
@@ -23,7 +23,7 @@ module Gitlab
# - name: g_compliance_dashboard # Unique event name
# redis_slot: compliance # Optional slot name, if not defined it will use name as a slot, used for totals
# category: compliance # Group events in categories
# expiry: 29 # Optional expiration time in days, defa
lu
t value 29 days for daily and 6.weeks for weekly
# expiry: 29 # Optional expiration time in days, defa
ul
t value 29 days for daily and 6.weeks for weekly
# aggregation: daily # Aggregation level, keys are stored daily or weekly
#
# Usage:
...
...
@@ -36,9 +36,7 @@ module Gitlab
raise
UnknownEvent
.
new
(
"Unknown event
#{
event_name
}
"
)
unless
event
.
present?
key
=
redis_key
(
event
,
time
)
Gitlab
::
Redis
::
HLL
.
add
(
key:
key
,
value:
entity_id
,
expiry:
expiry
(
event
))
Gitlab
::
Redis
::
HLL
.
add
(
key:
redis_key
(
event
,
time
),
value:
entity_id
,
expiry:
expiry
(
event
))
end
def
unique_events
(
event_names
:,
start_date
:,
end_date
:)
...
...
@@ -70,7 +68,7 @@ module Gitlab
end
def
known_events
@known_events
||=
YAML
.
load_file
(
Rails
.
root
.
join
(
KNOWN_EVENTS_PATH
)).
map
(
&
:with_indifferent_access
)
@known_events
||=
YAML
.
load_file
(
Rails
.
root
.
join
(
KNOWN_EVENTS_PATH
)).
map
(
&
:with_indifferent_access
)
end
def
known_events_names
...
...
@@ -93,11 +91,9 @@ module Gitlab
end
def
expiry
(
event
)
if
event
[
:expiry
].
present?
event
[
:expiry
]
else
event
[
:aggregation
].
to_sym
==
:daily
?
DEFAULT_DAILY_KEY_EXPIRY_LENGTH
:
DEFAULT_WEEKLY_KEY_EXPIRY_LENGTH
end
return
event
[
:expiry
]
if
event
[
:expiry
].
present?
event
[
:aggregation
].
to_sym
==
:daily
?
DEFAULT_DAILY_KEY_EXPIRY_LENGTH
:
DEFAULT_WEEKLY_KEY_EXPIRY_LENGTH
end
def
event_for
(
event_name
)
...
...
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
View file @
9572d85c
...
...
@@ -6,7 +6,7 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
let
(
:entity1
)
{
'dfb9d2d2-f56c-4c77-8aeb-6cddc4a1f857'
}
let
(
:entity2
)
{
'1dd9afb2-a3ee-4de1-8ae3-a405579c8584'
}
let
(
:entity3
)
{
'34rfjuuy-ce56-sa35-ds34-dfer567dfrf2'
}
let
(
:entity4
)
{
'
34rfjuuy-ce56-sa35-ds34-dferddddfrf2
'
}
let
(
:entity4
)
{
'
8b9a2671-2abf-4bec-a682-22f6a8f7bf31
'
}
let
(
:weekly_event
)
{
'g_analytics_contribution'
}
let
(
:daily_event
)
{
'g_search'
}
...
...
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