Skip to content

Instantly share code, notes, and snippets.

@rubyrider
Created July 13, 2013 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubyrider/5991318 to your computer and use it in GitHub Desktop.
Save rubyrider/5991318 to your computer and use it in GitHub Desktop.
# the day_statistics
include Mongoid::Document
field :date, type: Date
field :entity_id, type: Integer
field :todays_statistics, type: Hash
field :hotel_inventory, type: Hash
field :total_guest, type: Hash
field :todays_activity_count, type: Hash
field :item_type_activity_count, type: Hash
field :item_type_availability, type: Hash
field :item_type_checked_in, type: Hash
field :item_type_checked_out, type: Hash
field :item_type_reserved, type: Hash
field :item_type_maintenance, type: Hash
field :item_type_due_out, type: Hash
field :last_synced_at, type: Time
def day_statistics(entity_id, process_date)
active_items = ReportItem.where(entity_id: entity_id, active: true)
data = ReportItemDailyActivity.where(date: process_date, :entity_id => entity_id.to_i, second_shift: true).in(item_id: active_items.collect(&:reference_id),
status: Constants::CHECK_IN_STATUS_CODES)
data_for_departure = ReportItemDailyActivity.where(date: process_date, :entity_id => entity_id.to_i).in(item_id: active_items.collect(&:reference_id),
status: Constants::CHECK_IN_STATUS_CODES)
#data.each {|d| ap d}
ref_for_check_in = ReportItem.where(:entity_id => entity_id, active: true, guests_in_room: true).collect(&:reference_id)
return_hash ={}
data.each do |d|
return_hash[:todays_expected_guests] ||= 0
return_hash[:todays_expected_guests] += 1 if Constants::REPORT_EXPECTED_GUESTS_STATUS.include?(d.status) && (d.start_date ==
process_date)
return_hash[:todays_checkin] ||= 0
return_hash[:todays_checkin] += 1 if Constants::REPORT_CHECKED_IN_STATUS.include?(d.status) && (d.start_date <= process_date && process_date <= d.end_date)
return_hash[:no_show_reservation] ||= 0
return_hash[:no_show_reservation] += 1 if Constants::EXPECTED_RESERVATION_STATUSES.include?(d.status) && (d.start_date == process_date) #TO DO later
return_hash[:todays_reservation] ||= 0
return_hash[:todays_reservation] += 1 if Constants::REPORT_RESERVED_STATUS.include?(d.status) && (d.start_date == process_date)
return_hash[:todays_confirmed_reservation] ||= 0
return_hash[:todays_confirmed_reservation] += 1 if Constants::REPORT_CONFIRMED_STATUS == d.status && (d.start_date == process_date)
end
data_for_departure.each do |d|
return_hash[:todays_departure_guest] ||= 0
return_hash[:todays_departure_guest] += 1 if Constants::REPORT_CHECKED_IN_STATUS.include?(d.status) && d.end_date == process_date
end
return_hash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment