Class: ProductAnalyticsEvent

Inherits:
ApplicationRecord show all
Defined in:
app/models/product_analytics_event.rb

Constant Summary

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.count_by_graph(graph, days) ⇒ Object



23
24
25
# File 'app/models/product_analytics_event.rb', line 23

def self.count_by_graph(graph, days)
  group(graph).timerange(days).count
end

.count_collector_tstamp_by_day(days) ⇒ Object



27
28
29
30
31
32
# File 'app/models/product_analytics_event.rb', line 27

def self.count_collector_tstamp_by_day(days)
  group("DATE_TRUNC('day', collector_tstamp)")
    .reorder('date_trunc_day_collector_tstamp')
    .timerange(days)
    .count
end

Instance Method Details

#as_json_wo_emptyObject



34
35
36
# File 'app/models/product_analytics_event.rb', line 34

def as_json_wo_empty
  as_json.compact
end