#Esta tarea asigna la ubicacion de los meetings.
#NO REASIGNAS LAS MESAS QUE YA FUERON ASINGADAS.
#En cada bloque de tiempo asigna despues de la ultima mesa que se asigno.
c = BusinessConference.find(1089)
t = c.business_conference_participant_types.first
t.agenda.each do |key,block|
puts "block >>>>>>>>>>>>>>>>>>>>>"
tables_begin_on = 0
added = 0
asigned_tables = c.business_conference_meetings.where(start_date: block[0], end_date: block[1], status: 2).select("distinct location").group("location").pluck(:location)
asigned_tables = asigned_tables.select{|table| table.present? } if asigned_tables.present? and asigned_tables.count > 0
if asigned_tables.present?
asigned_tables.each do |table|
table_number = table.gsub(/[^0-9]/, '')
tables_begin_on = table_number.to_i if table_number.to_i > tables_begin_on
end
end
meetings = c.business_conference_meetings.where(start_date: block[0], end_date: block[1], status: 2)
puts "total: #{meetings.count} "
puts "begin to enunmerate on #{tables_begin_on}"
meetings.each do |m|
next if m.location.present?
tables_begin_on += 1
added += 1
m.update_column(:location, "Mesa #{tables_begin_on}")
end
puts "added #{added}"
puts "ending #{tables_begin_on}"
puts "block >>>>>>>>>>>>>>>>>>>>>"
end