feat: async combined student-report PDFs per school#82
Open
pritamps wants to merge 2 commits into
Open
Conversation
Generate one merged PDF of every student's report for a school on a given test, async via an SQS worker, sourced from the existing student_quiz_reports_v2 DynamoDB docs (no BigQuery). - combined_reports router: submit / status / list / retry, gated by X-Api-Key - ReportJobsDB: report_jobs table + status lifecycle (queued->...->done|errored) - worker (SQS-triggered Lambda): read v2 -> 3-way id roster filter -> render via the existing student_quiz_report_v2_print.html -> html_to_pdf -> pypdf merge -> S3; presigned download regenerated on each poll - service-key auth (fills the previously-unvalidated APIKeyHeader placeholder) - SAM (prod+staging): worker function + SQS queue + DLQ, env/IAM; S3 bucket referenced (managed outside the stack); deploy workflows pass the new params - docs/combined-reports-contract.md: the af_lms <-> reporting wire contract Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…limit)
Staging deploy failed: the combined-reports env additions pushed the API
function's environment over Lambda's 4KB cap. FIRESTORE_CREDENTIALS — a ~3KB
base64 service-account JSON — was 81% of the env (3136B of 3874B). Move it to
Secrets Manager, mirroring the existing BqCredentialsSecretName pattern:
- sessions_db: load the encoded key from FIRESTORE_CREDENTIALS_SECRET_NAME via
Secrets Manager; keep the raw FIRESTORE_CREDENTIALS env path for local dev
- SAM (prod+staging): FirestoreCredentialsSecretName param + env;
secretsmanager:GetSecretValue on the Firestore secret (was env var)
- workflows: a step syncs the FIRESTORE_CREDENTIALS GH secret into a per-env
Secrets Manager secret (reporting-firestore-creds-{staging,prod}) before
deploy; SAM passes only the name
Drops the API function env from ~4.1KB to ~1KB.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an async API + SQS worker to generate a combined student-report PDF for one school on one test — the self-serve replacement for the manual
etl-data-flow/flows/reportslaptop run, scoped to physical-centre size (~50–60 students). Driven from the af_lms school page (companion PR: avantifellows/af_lms).How it works
X-Api-Keyservice key (this PR also fills the previously-unvalidatedAPIKeyHeaderplaceholder). The end user is authorized by af_lms.queued → started → processing → done | errored; errored jobs are retryable.Infra (SAM, prod + staging)
avantifellows-combined-reports+report_jobsDynamoDB table are managed outside the stack (already created); the stack only references them.ReportingServiceApiKey(GH env secret, set) +ReportsBucketName.Verification
Validated end-to-end against live prod data (no deploy): real session (
AIET-01-G12-PCM, 40 students, JNV Palghar) → jobdone, 3-id match 40/40, merged 120-page PDF, presigned download. Also exercised locally through the af_lms school-page UI.See
docs/combined-reports-contract.mdfor the wire contract.🤖 Generated with Claude Code