Class: HhPackage::EarnPointRestaurantWorker

Inherits:
ApplicationWorker show all
Defined in:
app/workers/hh_package/earn_point_restaurant_worker.rb

Overview

This worker responsibility is re check and update all earn point flag

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#perform(restaurant_ids) ⇒ Object

Parameters:

  • restaurant_ids, (Array)

    array id of restaurants , ex: [1,2,3]



6
7
8
9
10
11
12
13
14
15
16
# File 'app/workers/hh_package/earn_point_restaurant_worker.rb', line 6

def perform(restaurant_ids)
  restaurants = Restaurant.where(id: restaurant_ids)
  restaurants.each do |restaurant|
    earn_points = restaurant.restaurant_packages.map(&:package).map(&:earn_point?)
    if earn_points.include?(true)
      restaurant.update_column(:earn_point, true)
    else
      restaurant.update_column(:earn_point, false)
    end
  end
end