Class: SupplejackApi::FacetedMetrics

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps, Concerns::QueryableByDate
Defined in:
app/models/supplejack_api/faceted_metrics.rb

Instance Method Summary collapse

Instance Method Details

#replace_periodsObject

MongoDB does not allow you to store hashes that have keys with peroids in the name Some of the copyrights contain version numbers which prevents them from being stored as keys directly. This replaces periods with the unicode equivalent


31
32
33
34
# File 'app/models/supplejack_api/faceted_metrics.rb', line 31

def replace_periods
  self.category_counts  = Hash[category_counts. map(&key_replacer('.', "\u2024"))] if category_counts
  self.copyright_counts = Hash[copyright_counts.map(&key_replacer('.', "\u2024"))] if copyright_counts
end

#replace_unicode_periodsObject

MongoDB does not allow you to store hashes that have keys with peroids in the name Some of the copyrights contain version numbers which prevents them from being stored as keys directly. This replaces unicode periods with normal periods so this quirk doesn't affect the application code


40
41
42
43
# File 'app/models/supplejack_api/faceted_metrics.rb', line 40

def replace_unicode_periods
  self.category_counts  = Hash[category_counts. map(&key_replacer("\u2024", '.'))] if category_counts
  self.copyright_counts = Hash[copyright_counts.map(&key_replacer("\u2024", '.'))] if copyright_counts
end