Class: Twinkle::Summary

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.empty_datapoints_hashObject



22
23
24
# File 'app/models/twinkle/summary.rb', line 22

def self.empty_datapoints_hash
  Event.fields.map { |name| [name, {}] }.append(['users', {}]).to_h
end

Instance Method Details

#hash_datapointsObject



14
15
16
17
18
19
20
# File 'app/models/twinkle/summary.rb', line 14

def hash_datapoints
  data = Event.fields.map { |name| [name, {}] }.append(['users', {}]).to_h
  datapoints.each do |datapoint|
    data[datapoint.name][datapoint.value] = datapoint.count
  end
  data
end