Class: Gitlab::Analytics::UniqueVisits
- Inherits:
-
Object
- Object
- Gitlab::Analytics::UniqueVisits
- Defined in:
- lib/gitlab/analytics/unique_visits.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#unique_visits_for(targets:, start_date: 7.days.ago, end_date: start_date + 1.week) ⇒ Integer
Returns number of unique visitors for given targets in given time frame.
Class Method Details
.analytics_events ⇒ Object
25 26 27 |
# File 'lib/gitlab/analytics/unique_visits.rb', line 25 def analytics_events Gitlab::UsageDataCounters::HLLRedisCounter.events_for_category('analytics') end |
.compliance_events ⇒ Object
29 30 31 |
# File 'lib/gitlab/analytics/unique_visits.rb', line 29 def compliance_events Gitlab::UsageDataCounters::HLLRedisCounter.events_for_category('compliance') end |
Instance Method Details
#unique_visits_for(targets:, start_date: 7.days.ago, end_date: start_date + 1.week) ⇒ Integer
Returns number of unique visitors for given targets in given time frame
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gitlab/analytics/unique_visits.rb', line 12 def unique_visits_for(targets:, start_date: 7.days.ago, end_date: start_date + 1.week) events = if targets == :analytics self.class.analytics_events elsif targets == :compliance self.class.compliance_events else Array(targets) end Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(event_names: events, start_date: start_date, end_date: end_date) end |