diff options
Diffstat (limited to 'app/models/product_analytics_event.rb')
-rw-r--r-- | app/models/product_analytics_event.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/product_analytics_event.rb b/app/models/product_analytics_event.rb index 95a2e7a26c4..579ea88c272 100644 --- a/app/models/product_analytics_event.rb +++ b/app/models/product_analytics_event.rb @@ -19,4 +19,12 @@ class ProductAnalyticsEvent < ApplicationRecord scope :timerange, ->(duration, today = Time.zone.today) { where('collector_tstamp BETWEEN ? AND ? ', today - duration + 1, today + 1) } + + def self.count_by_graph(graph, days) + group(graph).timerange(days).count + end + + def as_json_wo_empty + as_json.compact + end end |