Hi all
Im trying to track conflicts in Event Dates. So Im basically checking if
event dates overlap
This is the code my boss helped me with however its showing records as
overlapping when there is no conflict. Any ideas?
def perform (user_id)
user=User.find(user_id)
events=user.calendar.events
events.each do |e|
overlaps=events.where("(strftime('%s',start) -
strftime('%s',?)) * (strftime('%s',?) -
strftime('%s',end)) >= 0 ",
e.start, e.end)
#exclude event id
if overlaps.any? where.not("id = e.id") #something like
this
puts "FOUND AN OVERLAP"
end
end
#When using POSTGRES
#events.each do |e|
#e.start
#overlaps=events.where("(start, end) OVERLAPS (?,?)", e.start,
e.end)
end
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.