This PR fixes a previous when creating new timeslices as part of the pre-update process.
The bug affected pre-updates where users, wikis and course dates were updated at ~ the same time,
so all changes are taken into account in the same update run. Previously to this PR, duplicated timeslices were created.
The pre-update works in three steps (order matters). The logic is encapsulated in a new PrepareTimeslices class.
@update_timeslices_course_user.run: if a new course user was added, new course user wiki timeslices for current wikis and dates are created. Notice that if a wiki was added recently, course user wiki timeslices are created for it. Same thing for course start and end updates. On the other hand, if a course user was deleted, existing course user wiki timeslices for that user are deleted. In addition, articles courses only edited for that user need to be deleted (along with their respective timeslices).
@update_timeslices_course_wiki.run: if a new course wiki was added, course wiki timeslices and course user wiki timeslices are created for that new course wiki, considering current course users and dates. Notice that a recently added user will already have timeslices for that wiki. Unique constraint for timeslices avoids creating duplicate timeslices. On the other hand, if a course wiki is deleted, course wiki timeslices and course user wiki timeslices are deleted for that wiki. In addition, articles courses belonging to the deleted wiki need to be deleted (along with their respective timeslices).
@update_timeslices_course_date.run: if course dates (start or end) are modified, then all kind of timeslices need to be added or deleted to fit the new dates. Articles courses edited only during dates that don't belong to the course anymore need to be deleted too (along with their respective timeslices).
This PR adds two unique constraints: one for course user wiki timeslices and other one for article course timeslices.
Open questions and concerns
TODO: find a good way to add specs for PrepareTimeslices class.
What this PR does
This PR fixes a previous when creating new timeslices as part of the pre-update process. The bug affected pre-updates where users, wikis and course dates were updated at ~ the same time, so all changes are taken into account in the same update run. Previously to this PR, duplicated timeslices were created.
The pre-update works in three steps (order matters). The logic is encapsulated in a new
PrepareTimeslices
class.@update_timeslices_course_user.run
: if a new course user was added, new course user wiki timeslices for current wikis and dates are created. Notice that if a wiki was added recently, course user wiki timeslices are created for it. Same thing for course start and end updates. On the other hand, if a course user was deleted, existing course user wiki timeslices for that user are deleted. In addition, articles courses only edited for that user need to be deleted (along with their respective timeslices).@update_timeslices_course_wiki.run
: if a new course wiki was added, course wiki timeslices and course user wiki timeslices are created for that new course wiki, considering current course users and dates. Notice that a recently added user will already have timeslices for that wiki. Unique constraint for timeslices avoids creating duplicate timeslices. On the other hand, if a course wiki is deleted, course wiki timeslices and course user wiki timeslices are deleted for that wiki. In addition, articles courses belonging to the deleted wiki need to be deleted (along with their respective timeslices).@update_timeslices_course_date.run
: if course dates (start or end) are modified, then all kind of timeslices need to be added or deleted to fit the new dates. Articles courses edited only during dates that don't belong to the course anymore need to be deleted too (along with their respective timeslices).This PR adds two unique constraints: one for course user wiki timeslices and other one for article course timeslices.
Open questions and concerns
TODO: find a good way to add specs for
PrepareTimeslices
class.