course sync and cohort sync task optimisation#3033
Open
weilai-irl wants to merge 1 commit intoMOODLE_405_STABLEfrom
Open
course sync and cohort sync task optimisation#3033weilai-irl wants to merge 1 commit intoMOODLE_405_STABLEfrom
weilai-irl wants to merge 1 commit intoMOODLE_405_STABLEfrom
Conversation
Collaborator
weilai-irl
commented
Feb 19, 2026
- Consolidate local_o365_teams_cache into local_o365_groups_cache for course sync and cohort sync tasks.
- Extend local_o365_groups_cache with has_team, url, locked, team_details_last_attempted, lock_status_last_checked fields and supporting indexes.
- Drop local_o365_teams_cache table.
- Rewrite utils::update_groups_cache() to handle both groups and teams in one pass, with 5-minute rate limiting, lazy team-detail fetching (URL once, lock status every 7 days), and bulk DB operations.
- Replace two separate cache-update calls in the course sync task with a single unified call; fix cohort sync task to proceed on rate-limit skip rather than abort.
- Update all table references in tasks, admin UI, and deprecated update_teams_cache() to use the unified cache table.
There was a problem hiding this comment.
Pull request overview
This pull request optimizes course sync and cohort sync tasks by consolidating the separate local_o365_teams_cache and local_o365_groups_cache tables into a single unified cache table. The PR recognizes that every Microsoft Team is built on top of a Microsoft 365 Group with the same object ID, making separate tables redundant and inefficient.
Changes:
- Consolidates Teams and Groups caching into a single
local_o365_groups_cachetable with ahas_teamflag, adding team-specific fields (url, locked, team_details_last_attempted, lock_status_last_checked) and supporting indexes - Rewrites
utils::update_groups_cache()to handle both groups and teams in one pass with 5-minute rate limiting, lazy team detail fetching (URL once, lock status every 7 days), and bulk database operations to avoid N+1 queries - Updates course sync and cohort sync tasks to use the unified cache with a single API call, fixing cohort sync to proceed on rate-limit skip rather than abort
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| local/o365/version.php | Increments plugin version to 2024100725.01 |
| local/o365/db/upgrade.php | Adds migration logic to merge local_o365_teams_cache into local_o365_groups_cache, add new fields, indexes, and drop old table |
| local/o365/db/install.xml | Updates schema to define unified groups_cache table with team fields and composite indexes, removes teams_cache table definition |
| local/o365/classes/utils.php | Rewrites update_groups_cache() to handle both groups and teams with rate limiting, lazy detail fetching, and bulk operations; updates cleanup logic with different grace periods for groups vs teams |
| local/o365/classes/task/processcourserequestapproval.php | Updates team cache record query to use unified table with has_team filter |
| local/o365/classes/task/coursesync.php | Replaces separate cache update calls with single unified call, only runs cleanup when cache is actually refreshed |
| local/o365/classes/task/cohortsync.php | Updates to handle null return (rate limit skip) from cache update and proceed with existing cache |
| local/o365/classes/page/acp.php | Updates all teams cache queries to use groups_cache table with has_team filter, forces cache update on admin request |
| local/o365/classes/feature/coursesync/utils.php | Updates get_matching_team_options() to query groups_cache with has_team filter |
| local/o365/classes/feature/coursesync/main.php | Updates deprecated update_teams_cache() to use unified table, updates cleanup_teams_connections() and is_team_locked() queries |
| local/o365/classes/feature/cohortsync/main.php | Updates update_groups_cache() to return null for rate limit skip and handle three-way return value |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Consolidate local_o365_teams_cache into local_o365_groups_cache for course sync and cohort sync tasks.
- Extend local_o365_groups_cache with has_team, url, locked, team_details_last_attempted, lock_status_last_checked fields and supporting indexes.
- Drop local_o365_teams_cache table.
- Rewrite utils::update_groups_cache() to handle both groups and teams in one pass, with 5-minute rate limiting, lazy team-detail fetching (URL once, lock status every 7 days), and bulk DB operations.
- Replace two separate cache-update calls in the course sync task with a single unified call; fix cohort sync task to proceed on rate-limit skip rather than abort.
- Update all table references in tasks, admin UI, and deprecated update_teams_cache() to use the unified cache table.
6992256 to
faaee5c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.