WikiEducationFoundation / WikiEduDashboard

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

[Data rearchitecture] Support disenrolling users #5960

Closed gabina closed 2 months ago

gabina commented 2 months ago

What this PR does

This PR adds the ability to dis-enroll users in the middle of the course.

This is done through a new CourseUserUpdater class implemented with that purpose. When a course user record is removed, then we need to take the following actions:

  1. Remove course user wiki timeslices for deleted users.
  2. Mark the course wiki timeslices records as needs_update if it includes any edit done by a deleted user. To determine this we run a query against article_course_timeslices table to get all the records where user_ids includes any deleted user. Based on that query, we get pairs of wikis and dates where the deleted users made some edits. Those are the course wiki timeslices that need to be updated as needs_update. In addition, the retrieved article course timeslices records have to be cleaned.
  3. Remove articles courses records for articles courses that were only edited by deleted users. This is done through the ArticlesCoursesCleanerTimeslice.

This PR migrates course_wiki_timeslices table to add the new needs_update field. Now, before getting new revisions and updating new timeslices, we run a pre-update (where the CourseUserUpdater class is used). Then, we re-process all the timeslices marked as needs_update. After that, we fetch new data and process new timeslices.

Proposed flow:

Open questions and concerns

Note: while it's not mandatory, article course timeslices for deleted articles courses could be deleted too. The ArticlesCoursesCleanerTimeslice class itself could take care of that.