Skip to content

Asynchronous student import for Google Classroom integration - #1133

Open
zetter-rpf wants to merge 5 commits into
mainfrom
async-import-3
Open

zetter-rpf wants to merge 5 commits into
mainfrom
async-import-3

Conversation

@zetter-rpf

@zetter-rpf zetter-rpf commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Status

Points for consideration:

  • Security - This uses the users token in as an argument for the job. I don't really like this approach as it shares the token in more places and the token itself might become invalid. However, there's not good alternatives given the Profile API. We are already using this pattern in the SchoolImportJob.

What's changed?

We currently create student accounts (in profile) and student roles and class memberships (in editor-api) for the Google Classroom integration.

The profile API accepts up to 200 students, however we've found that it can timeout and cause errors in profile for ~100 students.

This keeps the class creation synchronous, but moves the student creation to a batched async method.

I've added progress reporting to the batch job so that we might be able to show progress on the frontend.

Steps to perform after deploying to production

Switch the frontend to use the new async option.

Extract existing code to the rspec config.

The ensure isn't needed as exceptions from specs are rescued (it would only help if we expect errors in the `around` itself)
@cla-bot cla-bot Bot added the cla-signed label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Test coverage

94.19% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/45417993272

@raspberrypiherokubot
raspberrypiherokubot temporarily deployed to editor-api-p-async-impo-iftdzd November 24, 2026 13:57 Inactive
This is lower level behaviour needed for importing students
@zetter-rpf
zetter-rpf temporarily deployed to editor-api-p-async-impo-iftdzd November 24, 2026 14:01 Inactive
@zetter-rpf zetter-rpf changed the title Async import 3 Asynchronous students import for Google Classroom integration Nov 24, 2026
@zetter-rpf
zetter-rpf marked this pull request as ready for review November 24, 2026 14:14
@macroscopeapp

macroscopeapp Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — The opt-in import batches student creation and exposes progress while preserving synchronous imports. Confirm that concurrent provisioning on the shared default queue is acceptable for Profile API capacity and other queued work; existing student-creation queue configuration explicitly preserves serial execution.

Needs human approval because:

  • approvability is in preview mode for this repository, so Macroscope does not approve PRs here

You can add or adjust custom eligibility rules. Learn more.

Currently profile can take more than 15s to create students.

I don't like using the users token in an async job- as well as creating a copy of it, it might expire before the job runs, but there's not really an alternative at the moment.
I want to avoid overloading profile. It might be possible to up this concurrency in the future as the code in editor shouldn't prevent it running in parallel.
Since this might take a minute or longer, I wanted to see if we could report
progress to the frontend so people can see that it's in progress and not got stuck.
@zetter-rpf zetter-rpf changed the title Asynchronous students import for Google Classroom integration Asynchronous student import for Google Classroom integration Nov 24, 2026

This branch was successfully deployed

1 active deployment
editor-api-p-async-impo-iftdzd — 20495c70 Deployed Nov 24, 2026 by zetter-rpf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants