Class: Restaurants::ClearUiCacheWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- Restaurants::ClearUiCacheWorker
- Defined in:
- app/workers/restaurants/clear_ui_cache_worker.rb
Overview
this class name was CleanCacheWorker
Instance Method Summary collapse
Methods inherited from ApplicationWorker
Instance Method Details
#perform(restaurant_id, by_admin = false, is_only_restaurant_data_updated = false) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/workers/restaurants/clear_ui_cache_worker.rb', line 7 def perform(restaurant_id, by_admin = false, is_only_restaurant_data_updated = false) restaurant = Restaurant.fetch(restaurant_id) restaurant.refresh_view_cache_key ActiveRecord::Base.transaction do restaurant.restaurant_packages.each do |rp| rp.touch rp.package.touch rp.package.agendas.each(&:touch) end end clear_cities_cache clear_opening_hours_cache(restaurant) clear_pegasus_cache_for_store_page(restaurant) Restaurants::UpdateAttributesWorker.new.perform(restaurant_id) if by_admin.to_s == 'true' today = Time.now_in_tz(restaurant.time_zone) InventoryReservationWorker.new.perform(restaurant.id, today.to_date, restaurant.expiry_date) end # no need to send update event if only restaurant data is updated # coming from persist! method in app/concepts/restaurant_cpt/operations/settings_by_owner.rb if is_only_restaurant_data_updated.to_s == 'false' if restaurant.bookable_and_not_expired? EventDrivenWorkers::HhSearch::ProducerWorker.perform_async( EventDrivenClient::Constants::RESTAURANTS_TOPIC, EventDrivenClient::Constants::CREATE_EVENT, restaurant_id, {}, { source: 'Restaurants::ClearUiCacheWorker#perform' }, ) else EventDrivenWorkers::HhSearch::ProducerWorker.perform_async( EventDrivenClient::Constants::RESTAURANTS_TOPIC, EventDrivenClient::Constants::DELETE_EVENT, restaurant_id, {}, { source: 'Restaurants::ClearUiCacheWorker#perform' }, ) end end rescue ActiveRecord::RecordNotFound APMErrorHandler.report("#{self.class} Restaurant not found: #{restaurant_id}") end |