Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make sync enrollments and sync assignments async with Good_job gem#345

Closed
gobears01 wants to merge 49 commits into
main from
async-requests
Closed

Make sync enrollments and sync assignments async with Good_job gem #345
gobears01 wants to merge 49 commits into
main from
async-requests

Conversation

@gobears01

@gobears01 gobears01 commented Apr 10, 2026

Copy link
Copy Markdown

General Info

We need a framework to run async functions in the background (show status syncing). Async cast (sync enrollments/assignments should show status). We don’t want to wait 30/ 60s as per the current implementation

Changes

Previously, "Sync Enrollments" and "Sync Assignments" were synchronous: the HTTP request would block until all Canvas API calls completed, which could take 30–60 seconds and risk timing out. This PR makes both operations asynchronous using GoodJob, a PostgreSQL-backed Active Job backend.

Background job infrastructure:
Added GoodJob gem and ran its migration to create the good_jobs table in Postgres
Configured config.active_job.queue_adapter = :good_job in application.rb
Added a Procfile so Heroku runs a separate worker dyno alongside web
Added dotenv-rails gem to support loading .env locally
Async sync behavior:
Course#sync_assignments and Course#sync_users_from_canvas now call perform_later instead of running inline; the controller returns immediately after enqueuing
Added GET /courses/:id/sync_status endpoint that returns the last roster_synced_at / assignments_synced_at timestamps from CourseToLms

UI:
Both sync buttons now disable and show a "Syncing..." label + spinner immediately on click
The Stimulus controllers poll /sync_status every 1 second and reload the page with a banner notification once the job's timestamp changes, confirming completion
On timeout (60s) or error, an alert flash is shown and the button re-enabled

Testing

Added a full RSpec spec for SyncUsersFromCanvasJob covering: user upsert, enrollment creation, role-based removal, multi-role sync, return values/persistence, and non-array Canvas error responses
Rewrote the stale pending spec for SyncAllCourseAssignmentsJob#sync_assignment to test the instance method directly (create, update, unchanged)
Updated course_spec to verify sync_users_from_canvas enqueues the job rather than running inline
Added Cucumber scenarios for both sync buttons: visibility, disabled state, and spinner appearance after clicking
Set config.good_job.execution_mode = :external in test.rb to prevent GoodJob from executing jobs in-process during tests (which would cause the page to reload before Capybara could assert on the loading state)

Documentation

No documentation needed

Checklist

  • Name of branch corresponds to story

alxstx and others added 30 commits March 4, 2026 19:45
Bumps the npm_and_yarn group with 1 update in the / directory: [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser).
Updates `fast-xml-parser` from 5.4.1 to 5.5.6
- [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases)
- [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md)
- [Commits](NaturalIntelligence/fast-xml-parser@v5.4.1...v5.5.6)
---
updated-dependencies:
- dependency-name: fast-xml-parser
 dependency-version: 5.5.6
 dependency-type: indirect
 dependency-group: npm_and_yarn
...
Signed-off-by: dependabot[bot] <support@github.com>
Mass approve/ reject functionality and UI changes for request table
...n; Use pluck('name') instead of map in specs. Fix find_by returning wrong enrollment by reusing course_admin? method that checks all enrollments.
...taff-view
Enrollments staff view and semester filter
gobears01 and others added 11 commits April 7, 2026 18:14
Bumps the bundler group with 1 update in the / directory: [rack-session](https://github.com/rack/rack-session).
Updates `rack-session` from 2.1.1 to 2.1.2
- [Release notes](https://github.com/rack/rack-session/releases)
- [Changelog](https://github.com/rack/rack-session/blob/main/releases.md)
- [Commits](rack/rack-session@v2.1.1...v2.1.2)
---
updated-dependencies:
- dependency-name: rack-session
 dependency-version: 2.1.2
 dependency-type: indirect
 dependency-group: bundler
...
Signed-off-by: dependabot[bot] <support@github.com>
Bumps the bundler group with 1 update in the / directory: [addressable](https://github.com/sporkmonger/addressable).
Updates `addressable` from 2.8.9 to 2.9.0
- [Changelog](https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md)
- [Commits](sporkmonger/addressable@addressable-2.8.9...addressable-2.9.0)
---
updated-dependencies:
- dependency-name: addressable
 dependency-version: 2.9.0
 dependency-type: indirect
 dependency-group: bundler
...
Signed-off-by: dependabot[bot] <support@github.com>
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.86.0 to 1.86.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](rubocop/rubocop@v1.86.0...v1.86.1)
---
updated-dependencies:
- dependency-name: rubocop
 dependency-version: 1.86.1
 dependency-type: direct:development
 update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Bumps [strong_migrations](https://github.com/ankane/strong_migrations) from 2.5.2 to 2.6.0.
- [Changelog](https://github.com/ankane/strong_migrations/blob/master/CHANGELOG.md)
- [Commits](ankane/strong_migrations@v2.5.2...v2.6.0)
---
updated-dependencies:
- dependency-name: strong_migrations
 dependency-version: 2.6.0
 dependency-type: direct:production
 update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
...ndler/bundler-2ba255671e
Bump addressable from 2.8.9 to 2.9.0 in the bundler group across 1 directory
@gobears01 gobears01 changed the title (削除) Make sync enrollments and sync assignment AJAX with Good_job gem (削除ここまで) (追記) Make sync enrollments and sync assignment async with Good_job gem (追記ここまで) Apr 10, 2026
@gobears01 gobears01 changed the title (削除) Make sync enrollments and sync assignment async with Good_job gem (削除ここまで) (追記) Make sync enrollments and sync assignments async with Good_job gem (追記ここまで) Apr 10, 2026
cycomachead and others added 2 commits April 13, 2026 10:58
...m_and_yarn-e78c89ff38
Bump fast-xml-parser from 5.4.1 to 5.5.6 in the npm_and_yarn group across 1 directory
Bumps the npm_and_yarn group with 3 updates in the / directory: [picomatch](https://github.com/micromatch/picomatch), [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) and [handlebars](https://github.com/handlebars-lang/handlebars.js).
Updates `picomatch` from 4.0.3 to 4.0.4
- [Release notes](https://github.com/micromatch/picomatch/releases)
- [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md)
- [Commits](micromatch/picomatch@4.0.3...4.0.4)
Updates `picomatch` from 2.3.1 to 2.3.2
- [Release notes](https://github.com/micromatch/picomatch/releases)
- [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md)
- [Commits](micromatch/picomatch@4.0.3...4.0.4)
Updates `fast-xml-parser` from 5.5.6 to 5.5.12
- [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases)
- [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/commits)
Updates `handlebars` from 4.7.8 to 4.7.9
- [Release notes](https://github.com/handlebars-lang/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.9/release-notes.md)
- [Commits](handlebars-lang/handlebars.js@v4.7.8...v4.7.9)
---
updated-dependencies:
- dependency-name: picomatch
 dependency-version: 4.0.4
 dependency-type: indirect
 dependency-group: npm_and_yarn
- dependency-name: picomatch
 dependency-version: 2.3.2
 dependency-type: indirect
 dependency-group: npm_and_yarn
- dependency-name: fast-xml-parser
 dependency-version: 5.5.12
 dependency-type: indirect
 dependency-group: npm_and_yarn
- dependency-name: handlebars
 dependency-version: 4.7.9
 dependency-type: indirect
 dependency-group: npm_and_yarn
...
Signed-off-by: dependabot[bot] <support@github.com>

@cycomachead cycomachead left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks pretty good!
I'll give more detailed feedback, but I don't think we need too many changes.

Can you enable the web dashboard and make sure it's behind checkin the user is an admin?
https://claude.ai/share/0c4d073f-0168-4277-a6c1-2425e47f0e28

Copy link
Copy Markdown
Author

This looks pretty good! I'll give more detailed feedback, but I don't think we need too many changes.

Can you enable the web dashboard and make sure it's behind checkin the user is an admin? https://claude.ai/share/0c4d073f-0168-4277-a6c1-2425e47f0e28
Confirmed. I can see admin/good_job on local deployment but cannot access on heroku deployment. In routes.rb:

This is protected by require_admin via blazer.yml

cycomachead and others added 5 commits April 13, 2026 18:53
...m_and_yarn/npm_and_yarn-56a676e30a
Bump the npm_and_yarn group across 1 directory with 3 updates
...ndler/rubocop-1.86.1
Bump rubocop from 1.86.0 to 1.86.1
...ndler/strong_migrations-2.6.0
Bump strong_migrations from 2.5.2 to 2.6.0
Comment thread config/routes.rb

# This is protected by `require_admin` via blazer.yml
mount Blazer::Engine, at: "admin/blazer"
mount GoodJob::Engine, at: "admin/good_job"

@cycomachead cycomachead Apr 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was this particular commit deployed to Heroku?

I just tried /admin/good_job and it didn't work (404), but /good_job less to a 500.

Copy link
Copy Markdown
Member

Thanks! One small question. I think the main branch or each repo should probably be synced up again

Copy link
Copy Markdown
Member

Actually I take that back /admin/good_job exists, but I think there's an error with the authentication for some reason.

Copy link
Copy Markdown
Author

Actually I take that back /admin/good_job exists, but I think there's an error with the authentication for some reason.

I think heroku was not happy because authentication was not added correctly. I fixed this by adding the authentication similar to how omniauth route authentication was added. I made a new PR with cdss rebasing at berkeley-cdss#390

so I am closing this PR. I'm sorry, the PR is getting bigger with all the fixes and rebasing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cycomachead cycomachead cycomachead left review comments

@ba88im ba88im Awaiting requested review from ba88im

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /