Skip to content

Commit

Permalink
Fix Query for the fetching of the events on calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Kapoor committed Jun 25, 2014
1 parent eb9844a commit 14468af
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/controllers/fullcalendar_engine/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ def new
end

def get_events
@events = Event.where('starttime >= :start_time and
endtime <= :end_time',
start_time: Time.at(params['start'].to_i).to_formatted_s(:db),
end_time: Time.at(params['end'].to_i).to_formatted_s(:db))
start_time = Time.at(params[:start].to_i).to_formatted_s(:db)
end_time = Time.at(params[:end].to_i).to_formatted_s(:db)

@events = Event.where('
(starttime >= :start_time and endtime <= :end_time) or
(starttime >= :start_time and endtime > :end_time and starttime <= :end_time) or
(starttime <= :start_time and endtime >= :start_time and endtime <= :end_time) or
(starttime <= :start_time and endtime > :end_time)',
start_time: start_time, end_time: end_time)
events = []
@events.each do |event|
events << { id: event.id,
Expand Down

0 comments on commit 14468af

Please sign in to comment.