Class: SupplejackApi::DailyMetricsWorker
- Inherits:
-
Object
- Object
- SupplejackApi::DailyMetricsWorker
- Defined in:
- app/workers/supplejack_api/daily_metrics_worker.rb
Instance Attribute Summary collapse
-
#primary_key ⇒ Object
readonly
Returns the value of attribute primary_key.
-
#secondary_keys ⇒ Object
readonly
Returns the value of attribute secondary_keys.
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
Uses
SupplejackApi::RecordSearch
to query the API for metrics information Metrics are grouped by the @primary_key variable set in the constructor Metric information extracted from each record is determined by the @secondary_keys variable. -
#initialize ⇒ DailyMetricsWorker
constructor
A new instance of DailyMetricsWorker.
Constructor Details
#initialize ⇒ DailyMetricsWorker
Returns a new instance of DailyMetricsWorker.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/workers/supplejack_api/daily_metrics_worker.rb', line 14 def initialize # configuration for metrics logging # the primary_key is what the records get grouped on # the secondary_keys are the fields counted, they must be multivalue fields # if the secondary_keys are changed the FacetedMetrics model must be updated # so that the field names match the new secondary_key names (the name must have '_counts' appended to it) @primary_key = 'display_collection' @secondary_keys = %w( category copyright ) end |
Instance Attribute Details
#primary_key ⇒ Object (readonly)
Returns the value of attribute primary_key.
11 12 13 |
# File 'app/workers/supplejack_api/daily_metrics_worker.rb', line 11 def primary_key @primary_key end |
#secondary_keys ⇒ Object (readonly)
Returns the value of attribute secondary_keys.
11 12 13 |
# File 'app/workers/supplejack_api/daily_metrics_worker.rb', line 11 def secondary_keys @secondary_keys end |
Class Method Details
.perform ⇒ Object
27 28 29 |
# File 'app/workers/supplejack_api/daily_metrics_worker.rb', line 27 def self.perform new.call end |
Instance Method Details
#call ⇒ Object
Uses SupplejackApi::RecordSearch
to query the API for metrics information Metrics are grouped by the @primary_key variable set in the constructor Metric information extracted from each record is determined by the @secondary_keys variable
The output of this worker is a SupplejackApi::DailyItemMetric
to represent metrics about the overall system and one SupplejackApi::FacetedMetrics
for each set of records grouped by the @primary_key
37 38 39 40 41 42 43 |
# File 'app/workers/supplejack_api/daily_metrics_worker.rb', line 37 def call facets = FacetsHelper.get_list_of_facet_values(primary_key) partial_facets_data = facets.map(&method(:retrieve_facet_data)) full_facets_data = update_total_new_records(partial_facets_data) create_metrics_records(full_facets_data) create_daily_metrics end |