Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-60352

repeat_event_collection does not sort and skips first result

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • 3.3.3
    • 3.3.2, 3.4
    • Calendar

      So this has just arrived due to a change in the existing indexes I suspect.

      The repeat_event_collection does not consider the original event to be part of the collection.
      Additionally, when fetching the events, it skips the first event, and does not sort them.

      Considering the following situation:

      Original: id 13, repeatid 13
      Repeat 1: id 8, repeatid 13
      Repeat 2: id 10, repeatid 13
      Repeat 3: id 12, repeatid 13
      

      If sorted as above, then the current query:

      SELECT * FROM event WHERE repeatid = 13 LIMIT 100 START 1
      

      Will return:

      • Repeat 1
      • Repeat 2
      • Repeat 3

      We apply a default start value of 1, which removes the first record

      Now assume that we sort by id, we'll instead get:

      • Repeat 2
      • Repeat 3
      • Original

      We could sort by timestort, but that's probably not ideal.

      I think we have two options:

      1. actively exclude WHERE id = ? and sort by id ASC
      2. actively exclude WHERE id = ? and sort by COALESCE(timesort, timestart) ASC

      Since the actual order does not matter, I vote we go for the cheapest order (id).

      As a third consideration, we need to decide whether a repeat event collection should actually contain the original event too. I think we'll discuss that in a separate issue due to the change of behaviour.
      This currently causes unit test failures on Oracle:

      1) core_calendar_repeat_event_collection_testcase::test_values_collection
      Undefined index: event name
       
      /var/www/html/moodle/calendar/tests/repeat_event_collection_test.php:118
      /var/www/html/moodle/lib/phpunit/classes/advanced_testcase.php:80
      
      

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Jake Dallimore Jake Dallimore
            Jun Pataleta Jun Pataleta
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.