Class: PartnerService::Reports::SalesAndRatingService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/partner_service/reports/sales_and_rating_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#params, #restaurants

Instance Method Summary collapse

Methods inherited from BaseService

#build_reports_by_day, #build_reports_by_hour, #initialize

Methods included from CopperHelper

#copper_sort_restaurants

Constructor Details

This class inherits a constructor from PartnerService::Reports::BaseService

Instance Method Details

#build_ratingsObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/services/partner_service/reports/sales_and_rating_service.rb', line 4

def build_ratings
  start_date = report_params[:start_date]
  end_date = report_params[:end_date]
  data_cache_key = cache_key('ratings')

  Rails.cache.fetch(data_cache_key) do
    if restaurants.size == 1
      fetch_individual_ratings(restaurants.first, start_date, end_date)
    else
      fetch_aggregated_ratings(start_date, end_date)
    end
  end
end