Skip to content

Commit

Permalink
Merge pull request #122 from mael-chouteau/master
Browse files Browse the repository at this point in the history
Improving query speed
  • Loading branch information
berti92 authored Aug 29, 2024
2 parents a0a7d87 + 4bf523c commit 8550ba3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/controllers/calendar_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ def get_events
if fuser.blank?
holidays = Holiday.where(['((holidays.start <= ? AND holidays.'+( ActiveRecord::Base.connection.adapter_name.downcase == 'sqlserver' ? '[end]' : 'end' )+' >= ?) OR (holidays.start BETWEEN ? AND ?) OR (holidays.'+( ActiveRecord::Base.connection.adapter_name.downcase == 'sqlserver' ? '[end]' : 'end' )+' BETWEEN ? AND ?))',fbegin.to_s,fend.to_s,fbegin.to_s,fend.to_s,fbegin.to_s,fend.to_s]).where(holidays_condition) rescue []
issues = Issue.where(['((issues.start_date <= ? AND issues.due_date >= ?) OR (issues.start_date BETWEEN ? AND ?) OR (issues.due_date BETWEEN ? AND ?))',fbegin.to_s,fend.to_s,fbegin.to_s,fend.to_s,fbegin.to_s,fend.to_s]).where(issues_condition) rescue []
issues2 = Issue.where(['issues.start_date >= ? AND issues.due_date IS NULL',fbegin.to_s]).where(issues_condition) rescue []
issues3 = Issue.where(['issues.start_date IS NULL AND issues.due_date <= ?',fend.to_s]).where(issues_condition) rescue []
issues2 = Issue.where(['issues.start_date >= ? AND issues.start_date <= ? AND issues.due_date IS NULL',fbegin.to_s,fend.to_s]).where(issues_condition) rescue []
issues3 = Issue.where(['issues.start_date IS NULL AND issues.due_date <= ? AND issues.due_date >= ?',fend.to_s,fbegin.to_s]).where(issues_condition) rescue []
if Setting.plugin_mega_calendar['display_empty_dates'].to_i == 1
issues4 = Issue.where(['issues.start_date IS NULL AND issues.due_date IS NULL AND (issues.created_on BETWEEN ? AND ?)',fbegin.to_s,fend.to_s]).where(issues_condition) rescue []
else
Expand All @@ -210,8 +210,8 @@ def get_events
cur_user_ids += User.current.groups.collect{|x| x.id} rescue []
holidays = Holiday.where(['((holidays.start <= ? AND holidays.'+( ActiveRecord::Base.connection.adapter_name.downcase == 'sqlserver' ? '[end]' : 'end' )+' >= ?) OR (holidays.start BETWEEN ? AND ?) OR (holidays.'+( ActiveRecord::Base.connection.adapter_name.downcase == 'sqlserver' ? '[end]' : 'end' )+' BETWEEN ? AND ?)) AND (holidays.user_id = ? OR holidays.user_id IS NULL)',fbegin.to_s,fend.to_s,fbegin.to_s,fend.to_s,fbegin.to_s,fend.to_s,User.current.id]).where(holidays_condition) rescue []
issues = Issue.where(['((issues.start_date <= ? AND issues.due_date >= ?) OR (issues.start_date BETWEEN ? AND ?) OR (issues.due_date BETWEEN ? AND ?)) AND issues.assigned_to_id IN (?)',fbegin.to_s,fend.to_s,fbegin.to_s,fend.to_s,fbegin.to_s,fend.to_s,cur_user_ids]).where(issues_condition) rescue []
issues2 = Issue.where(['issues.start_date >= ? AND issues.due_date IS NULL AND issues.assigned_to_id IN (?)',fbegin.to_s,cur_user_ids]).where(issues_condition) rescue []
issues3 = Issue.where(['issues.start_date IS NULL AND issues.due_date <= ? AND issues.assigned_to_id IN (?)',fend.to_s,cur_user_ids]).where(issues_condition) rescue []
issues2 = Issue.where(['issues.start_date >= ? AND issues.start_date <= ? AND issues.due_date IS NULL AND issues.assigned_to_id IN (?)',fbegin.to_s,fend.to_s,cur_user_ids]).where(issues_condition) rescue []
issues3 = Issue.where(['issues.start_date IS NULL AND issues.due_date <= ? AND issues.due_date >= ? AND issues.assigned_to_id IN (?)',fend.to_s,fbegin.to_s,cur_user_ids]).where(issues_condition).where(issues_condition) rescue []
issues4 = Issue.where(['issues.start_date IS NULL AND issues.due_date IS NULL AND issues.assigned_to_id IN (?)',cur_user_ids]).where(issues_condition) rescue []
end
if Setting.plugin_mega_calendar['display_empty_dates'].to_i == 1
Expand Down

0 comments on commit 8550ba3

Please sign in to comment.