WikiEducationFoundation / WikiEduDashboard

Wiki Education Foundation's Wikipedia course dashboard system
https://dashboard.wikiedu.org
MIT License
392 stars 631 forks source link

[Data rearchitecture] Add support for course start and end date updates #6001

Closed gabina closed 1 month ago

gabina commented 1 month ago

What this PR does

This PR adds support for updating course start and end dates. There are 4 main cases to take into account:

  1. The start date changes to a later date. In that case, we need to remove course wiki, course user wiki and articles courses timeslices from the previous start date up until the new one. Additionally, if any articles were only edited during that period, we may need to remove their associated article courses, along with the timeslices for those articles throughout the entire course.
  2. The start date changes to a previous date. In that case, we only need to create new course wiki and course user wiki timeslices from the new start date up until the previous start date. Timeslices for that period needs to be created as needs_update, so that the timeslices will be processed in the next update.
  3. The end date changes to a later date. Similar to 2.
  4. The end date changes to a previous date. Similar to 1.

Important behavior changes: Before this PR, whenever the start date for a course gets updated, we set the course as 'needs_update' (see the course callback set_needs_update) . In the timeslice world, we want to do something less drastic. If the start date changes, we don't need to re-calculate the stats for the entire course, but we only need to mark the new first course timeslice as needs_update and add new timeslices (if the new start date is previous to the old one) or remove existing timeslices (if the new start date is later than the old one). Because of this, this PR replaces the set_needs_update course callback with a new set_needs_update_timeslice callback. This change broke the schedule_course_updates specs, which gets fixed in commit ae28c7d89b966935915e277e664f851a17a69b9e.

Prior to this PR, timeslices were created starting 3 days before the course start date to mitigate a previous issue where no timeslices were found for certain dates. This is not really necessary, so we reverted that behavior in this PR, and timeslices are now created right from the course start date.

Open questions and concerns