Skip to content

AAI-326#69

Merged
marius-mather merged 23 commits into
mainfrom
auth0-sync
Sep 16, 2025
Merged

AAI-326#69
marius-mather merged 23 commits into
mainfrom
auth0-sync

Conversation

@marius-mather

@marius-mather marius-mather commented Sep 16, 2025

Copy link
Copy Markdown
Collaborator

Description

AAI-326: set up a job scheduling system that can be used for regular syncing of data between Auth0 and our user database.

Note that currently, the only data we expect to differ between Auth0 and the DB is email_verified status

Changes

  • Add email_verified status to the user database
  • Add migration for database change
  • Add apscheduler as a job queue - needs to be run separately from the main FastAPI app
  • Scheduled tasks to fetch all users from Auth0 and update the DB if needed

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have added unit / integration tests that prove my fix is effective or that my feature works
  • I have run all tests locally and they pass
  • I have updated the documentation (if applicable)

How to Test Manually (if necessary)

Run uv run python run_scheduler.py to run the scheduler - example logs:

Screenshot 2025-09-16 at 1 44 53 pm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a job scheduling system using APScheduler to sync user data between Auth0 and the local database, focusing on email_verified status synchronization.

  • Add email_verified field to the user database with migration
  • Implement APScheduler-based job queue with SQLAlchemy jobstore for periodic Auth0 sync
  • Create scheduled tasks to fetch users from Auth0 and update database records when needed

Reviewed Changes

Copilot reviewed 14 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
db/models.py Add email_verified field and update methods for Auth0 data synchronization
migrations/versions/1546c07b9d78_user_email_verified.py Database migration to add email_verified column with default false
scheduled_tasks/scheduler.py Configure APScheduler with SQLAlchemy jobstore and event listeners
scheduled_tasks/tasks.py Implement Auth0 user sync and individual user update tasks
run_scheduler.py Main scheduler application with signal handling and job scheduling
tests/scheduled_tasks/test_tasks.py Unit tests for sync and update tasks
pyproject.toml Add APScheduler, loguru, and pytest-asyncio dependencies
Various test files Update tests to handle new email_verified field and engine mocking

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread scheduled_tasks/tasks.py Outdated
Comment thread scheduled_tasks/scheduler.py Outdated

@amandazhuyilan amandazhuyilan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested changes locally :) thanks!

@marius-mather marius-mather merged commit 015ec40 into main Sep 16, 2025
2 checks passed
@amandazhuyilan amandazhuyilan deleted the auth0-sync branch November 24, 2025 22:23
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