Skip to content

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

Open
gobears01 wants to merge 48 commits intomainfrom
async-requests
Open

Make sync enrollments and sync assignments async with Good_job gem#345
gobears01 wants to merge 48 commits intomainfrom
async-requests

Conversation

@gobears01
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.
…er-filter

Add semester filter to Import Courses page
…dates

A bunch of small dependency updates
…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
@gobears01 gobears01 requested a review from ba88im April 10, 2026 18:58
cycomachead and others added 2 commits April 13, 2026 10:58
…m_and_yarn/npm_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>
Copy link
Copy Markdown
Member

@cycomachead cycomachead left a comment

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

@gobears01
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

# This is protected by `require_admin` via blazer.yml
mount Blazer::Engine, at: "admin/blazer"
mount GoodJob::Engine, at: "admin/good_job"
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.

@cycomachead
Copy link
Copy Markdown
Member

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

@cycomachead
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.

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.

3 participants