Cuando hay reuniones en slots que van a ser restringidos
meetings = BusinessConferenceMeeting.where(business_conference_id: 4172).where.not(status: 3).where("start_date = '2018-10-25 11:50:00'").where("end_date = '2018-10-25 12:10:00'")
meetings.each do |meeting|
host_participant_id = meeting.host_participant_id
participant_id = meeting.participant_id
#available_slots = get_available_slots_for_meeting(host_participant_id, participant_id)
participant = BusinessConferenceParticipant.find(participant_id)
host_participant = BusinessConferenceParticipant.find(host_participant_id)
common_agenda = participant.participant_type.agenda.values & host_participant.participant_type.agenda.values
cnn = ActiveRecord::Base.connection
unavailable_agenda = cnn.execute("SELECT DISTINCT start_date, end_date FROM
business_conference_meetings WHERE business_conference_id = 4172 AND
( host_participant_id = #{host_participant_id} OR participant_id = #{host_participant_id}
OR host_participant_id = #{participant_id} OR participant_id = #{participant_id} )
AND archived = false AND status != 3 order by start_date;").to_a
available_slots = common_agenda - unavailable_agenda
available_slots.each do |available_slot|
meeting.update_columns(status: 3, archived: true)
r = BusinessConferenceMeeting.add_new(4172, host_participant_id, participant_id, available_slot[0], '', nil, BusinessConferenceMeeting::SOURCE[:admin], true, false)
break if r[0].present?
end
end