Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix event fetch query #9

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/controllers/fullcalendar_engine/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def new
end
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))
def index
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 >= ? or endtime <= ?', start_time, end_time)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets not use OR in this query. Lets try to find those events which lies in given interval start_time and end_time.
Else it would return very large data set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the issue #9 is valid...


events = []
@events.each do |event|
events << { id: event.id,
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
'timeFormat' => "h:mm t{ - h:mm t}"
}
FullcalendarEngine::Configuration.merge!(config)
FullcalendarEngine::Configuration['events'] = "#{FullcalendarEngine::Configuration['mount_path']}/events/get_events"
FullcalendarEngine::Configuration['events'] = "#{FullcalendarEngine::Configuration['mount_path']}/events"
7 changes: 2 additions & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
FullcalendarEngine::Engine.routes.draw do
root :to => 'events#index'
resources :events do
collection do
get :get_events
end
resources :events do
member do
post :move
post :resize
end
end
root to: 'events#index'
end