sacarmonar15
9/22/2017 - 5:22 PM

Free Slots

#Esta tarea encuentra los slots libres 
#para cada participante en una rueda de negocios
results  = []
c = BusinessConference.find(526)
t = c.business_conference_participant_types.first
t.agenda.each do |key,block|
  joins = "p left join business_conference_meetings m on (m.host_participant_id = p.id or m.participant_id = p.id)"
  conditions = "p.business_conference_id = 526 and p.archived = false and p.draft = false and m.start_date = ?"
  having =  "(count(if((m.archived=false and m.id is not null),1,NULL)) = 0)"
  participants = BusinessConferenceParticipant.select("p.*").joins(joins).group("p.id").where(conditions, block[0]).having(having)
  participants.each do |participant|
    results << ["#{block[0].strftime('%r')}-#{block[1].strftime('%r')}", participant.participant_type.name, participant.profile_display_name]
  end
end