order upcoming_events by start_at in db

test plan:
* when a user has more than 20 upcoming events, the earliest
events should always be shown first

closes #CNVS-29897

Change-Id: I22e79bb1203831e242646d26e95c2e1e2d3a6f9a
Reviewed-on: https://gerrit.instructure.com/90686
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: David Tan <dtan@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2016-09-19 11:19:43 -06:00
parent aff2f3cd43
commit 8a29955719
1 changed files with 1 additions and 1 deletions

View File

@ -1964,7 +1964,7 @@ class User < ActiveRecord::Base
section_codes = self.section_context_codes(context_codes, filter_after_db)
limit = filter_after_db ? opts[:limit] * 2 : opts[:limit] # pull extra events just in case
events = CalendarEvent.active.for_user_and_context_codes(self, context_codes, section_codes).
between(now, opts[:end_at]).limit(limit).to_a.reject(&:hidden?)
between(now, opts[:end_at]).limit(limit).order(:start_at).to_a.reject(&:hidden?)
if filter_after_db
original_count = events.count