Class: Admin::GygRestaurantsController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/gyg_restaurants_controller.rb

Constant Summary

Constants inherited from BaseController

BaseController::INTERNAL_SERVER_ERROR_MESSAGE

Instance Method Summary collapse

Methods inherited from BaseController

#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from AdminHelper

#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?

Methods included from UpdateLocaleConcern

#setup_locale

Methods inherited from ApplicationController

#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=

Methods included from ControllerHelpers

#check_boolean_param, #get_banners, #inventory_params, #reservation_params

Instance Method Details

#indexObject



4
5
6
7
8
9
# File 'app/controllers/admin/gyg_restaurants_controller.rb', line 4

def index
  @gyg_restaurants = VendorRestaurant.where(oauth_application_id: @vendor_id)
  @active_restaurant_count = Restaurant.where(id: @gyg_restaurants.pluck(:restaurant_id)).active.not_expired.count
  @inactive_restaurant_count = @gyg_restaurants.count - @active_restaurant_count
  @restaurants = Restaurant.includes(:translations).active.not_expired
end

#updateObject



11
12
13
14
15
16
17
18
19
# File 'app/controllers/admin/gyg_restaurants_controller.rb', line 11

def update
  if params.dig(:report, :commit).present?
    restaurant_ids = params.fetch(:restaurants, {}).fetch(:ids, []).reject(&:blank?).map(&:to_i)
    save_restaurant_lists(restaurant_ids)
    render json: { success: true }
  else
    render json: { success: false, error: "Unknown action" }
  end
end