Skip to content

Instantly share code, notes, and snippets.

[user]
name = m-nakamura145
email = masato.nakamura145@gmail.com
[color]
ui = true
diff = auto
status = auto
branch = auto
interactive = auto
[user]
name = hoge
email = fuga
[color]
ui = true
diff = auto
status = auto
branch = auto
interactive = auto
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
# コマンドライン引数で指定した店舗IDをデモ利用可能店舗として追加する。
restaurant_id = ARGV[0].to_i
raise "invalid restaurant id: #{ARGV[0]}" if restaurant_id.zero?
raise "restaurant_id : #{ARGV[0]} not found." unless Restaurant.exists?(restaurant_id)
property = SystemProperty.find_by(key: 'demo_restaurants')
demo_restaurant_ids = JSON.parse(property.value)
if demo_restaurant_ids.include?(restaurant_id)
Restaurant.exists?('hoge')
# => Restaurant Exists (4.5ms) SELECT 1 AS one FROM `restaurants` WHERE `restaurants`.`id` = 0 LIMIT 1
# == Schema Information
#
# Table name: system_properties
#
# id :integer not null, primary key
# key :string(255) not null
# value :text(65535) not null
# description :text(65535)
# created_at :datetime
# updated_at :datetime
require 'worker/base_worker'
class OpenRestaurantCsvWorker < BaseWorker
sidekiq_options queue: :default, retry: 3
def self.dispatch
restaurant_ids = Restaurant.open.pluck(:id)
Sidekiq::Client.push_bulk(
'queue' => :default,
'class' => self,
require 'worker/base_worker'
class NotifyVisitedReservationWorker < BaseWorker
sidekiq_options queue: :reservation, retry: 3
def perform(reservation_id)
reservation = Reservation.find(reservation_id)
reservation.notify_visited
end
end
require 'worker/base_worker'
class NotifyCancelledReservationWorker < BaseWorker
sidekiq_options queue: :reservation, retry: 3
def perform(reservation_id)
reservation = Reservation.find(reservation_id)
reservation.notify_cancelled
end
end
require 'worker/base_worker'
class DispatchOpenRestaurantCsvWorker < BaseWorker
sidekiq_options queue: :default, retry: 1
def perform
OpenRestaurantCsvWorker.dispatch
end
end