Skip to content

Instantly share code, notes, and snippets.

@niyando
Last active December 3, 2019 21:34
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 niyando/1b5ce0962bebdc4f834ecdf9627dfa63 to your computer and use it in GitHub Desktop.
Save niyando/1b5ce0962bebdc4f834ecdf9627dfa63 to your computer and use it in GitHub Desktop.
create_work_queue_items
tallies = Tally.discharge.where(organization_id: [64,8,1]).where('started_at > (?)', DateTime.now - 30.hours).not_closed
tallies.each do |tally|
wq = tally.voyage.work_queue
next if wq.blank?
tally.tallied_cargos.each do |tallied_cargo|
next if tallied_cargo.work_queue_item.present?
tallied_cargo.organization.work_queue_items.create(
work_queue: tallied_cargo.tally.voyage.work_queue,
source: tallied_cargo.berth_area,
destination: tallied_cargo.tally.voyage.discharge_destination.suggested_yard_slot(tallied_cargo.container),
container: tallied_cargo.container,
voyage: tallied_cargo.tally.voyage,
tallied_cargo_id: tallied_cargo.id
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment