Skip to content

Comments

course sync and cohort sync task optimisation#3033

Open
weilai-irl wants to merge 1 commit intoMOODLE_405_STABLEfrom
wip-122433-m405
Open

course sync and cohort sync task optimisation#3033
weilai-irl wants to merge 1 commit intoMOODLE_405_STABLEfrom
wip-122433-m405

Conversation

@weilai-irl
Copy link
Collaborator

  • 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.

Copilot AI review requested due to automatic review settings February 19, 2026 12:23
@weilai-irl weilai-irl self-assigned this Feb 19, 2026
@weilai-irl weilai-irl added this to the 2026-01 milestone Feb 19, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_cache table with a has_team flag, 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant