Class: RestaurantNameListService
- Inherits:
-
Object
- Object
- RestaurantNameListService
- Includes:
- ElasticAPM::SpanHelpers
- Defined in:
- app/services/restaurant_name_list_service.rb
Overview
Service class to handle restaurant listing with name filtering only Provides pagination, filtering by name, and caching capabilities for restaurant data Does not include master menu filtering unlike RestaurantListService
Instance Method Summary collapse
-
#cache_key ⇒ String
Generate cache key for caching the response.
-
#call ⇒ Hash
Execute the restaurant listing logic with name filtering only.
-
#initialize(params) ⇒ RestaurantNameListService
constructor
A new instance of RestaurantNameListService.
Constructor Details
#initialize(params) ⇒ RestaurantNameListService
Returns a new instance of RestaurantNameListService.
7 8 9 |
# File 'app/services/restaurant_name_list_service.rb', line 7 def initialize(params) @params = params end |
Instance Method Details
#cache_key ⇒ String
Generate cache key for caching the response
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/services/restaurant_name_list_service.rb', line 13 def cache_key [ self.class.to_s, CityHash.hash32(@params), 'restaurant_name_lists', I18n.locale, @params[:name_like], "page:#{page}", "per_page:#{per_page}", "updated_at:#{Restaurant.maximum(:updated_at).to_i}", ].join('|') end |
#call ⇒ Hash
Execute the restaurant listing logic with name filtering only
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/services/restaurant_name_list_service.rb', line 28 def call restaurants = build_base_query restaurants = apply_name_filter(restaurants) if @params[:name_like].present? total_entries = restaurants.count restaurants = paginate_restaurants(restaurants) restaurants_data = format_restaurants_data(restaurants) build_response(restaurants_data, total_entries) rescue StandardError => e HH_LOGGER.error('Error in RestaurantNameListService#call', { error: e., params: @params }) APMErrorHandler.report(e, context: { params: @params }) { success: false, message: 'Failed to fetch restaurants' } end |