Repository navigation
Extend promotional classification toggle to OCR review - #116
Closed
thejonathangu wants to merge 7 commits into
Closed
thejonathangu wants to merge 7 commits into
thejonathangu wants to merge 7 commits into
Conversation
Admin mail-entry form gains an optional "Promotional" checkbox, gated behind a new FEATURE_PROMO_CLASSIFICATION flag (default off). Stored as an optional isPromotional boolean on the MAIL document — present only when true on create, explicit true|false on PATCH. No user-facing effect today; foundation for future summary/notification filtering.
Queue image uploads now write to a host-bind-mounted volume at IMAGE_STORE_DIR (default /var/lib/avenu/images) instead of GridFS. OCR_QUEUE_ITEM gains an optional imagePath field; fileId stays as a read-time fallback for legacy rows so no migration is needed. A new FEATURE_OCR_AUTO_EXTRACT flag gates background OCR — when off (default) uploads land as pending for manual review, letting admins snap photos on their phone and fill in receiver/sender on desktop. Nightly at 03:00 local, the scheduler hits a new internal endpoint POST /api/internal/jobs/image-prune which deletes files + soft-deletes rows past IMAGE_RETENTION_HOURS (24h default), plus sweeps orphaned files. Scheduler now dispatches weekly-summary and image-prune as independent cron jobs.
App.tsx was copying only three of the five fields returned by /api/feature-flags into the Zustand store, so `ocrAutoExtract` and `promoClassification` were permanently stuck at their default `false` regardless of backend configuration. Pass every field through. Made-with: Cursor
Extends the OCR queue so admins can tag an item as promotional during the review step (same gate as the manual record-entry form: FEATURE_PROMO_CLASSIFICATION / promoClassification). - Queue items now persist `isPromotional` (default false); surfaced on GET and settable via PATCH /api/ocr/queue/:id. - POST /api/ocr/queue/:id/confirm forwards `isPromotional: true` into the created mail record when set, matching the existing MAIL shape (omitted when false). - OcrQueue.tsx renders a Promotional checkbox between Type and Mailbox when the flag is on, persisting immediately via PATCH like the Type selector so it survives navigation. Made-with: Cursor
- .env.sample: rewrite the FEATURE_PROMO_CLASSIFICATION comment, which claimed no user-facing effect; the flag now gates the toggle on both the record-entry form and the OCR queue review screen. - data-model.md / data-model.mmd: add `isPromotional` to OCR_QUEUE_ITEM and fill in the previously-undocumented `fileId` / `imagePath` fields alongside it. Made-with: Cursor
Contributor
|
Closed per duplicate #119 |
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.
Summary
Closes the gap that left
FEATURE_PROMO_CLASSIFICATIONwired into the manual mail-entry form but missing from the OCR-driven path. Admins can now tag a mail piece as promotional while reviewing OCR results, and the flag is persisted end-to-end into the resultingMAILdocument — matching the existingRecordEntrybehavior.Along the way, fixes a silent bug where
/api/feature-flagsresponses were being filtered down to three fields insideApp.tsx, sopromoClassification(andocrAutoExtract) never reached the store no matter what the backend returned. This is what was hiding the existingRecordEntrytoggle as well once the flag was turned on.What's in here
Bug fix — feature-flag hydration (
App.tsx)setFeatureFlagsnow passes every flag through from the API response. No behavior change when flags are off.OCR queue — promotional classification
ocr_queue_itemsdocuments get anisPromotional: boolfield (defaultfalse).PATCH /api/ocr/queue/:idacceptsisPromotional(gated onFEATURE_PROMO_CLASSIFICATION; silently ignored when the flag is off).POST /api/ocr/queue/:id/confirmforwardsisPromotional: trueintocreate_mailwhen set; omitted when false, matching the existingMAILshape.ApiOcrQueueItemand the PATCH payload type carryisPromotional.OcrQueue.tsxrenders a "Promotional" checkbox between Type and Mailbox whenpromoClassificationis on, persisting immediately via PATCH (same pattern as the Type selector, so the value survives navigation).Docs
.env.sample: rewrite the outdatedFEATURE_PROMO_CLASSIFICATIONcomment to reflect both admin surfaces.data-model.md/data-model.mmd: addisPromotionaltoOCR_QUEUE_ITEMS; also fill in the previously-undocumentedfileId/imagePathfields on the same entity.Behavior matrix
FEATURE_PROMO_CLASSIFICATIONisPromotionalisPromotionalon mailfalse(default)trueNo indexes, no migration, no backfill —
isPromotionalis a new optional boolean onocr_queue_itemsand simply absent on older docs, which is equivalent tofalse.Out of scope
Test plan
cd backend && coverage run -m unittest discover -s tests/unit -p "test_*.py" -t . && coverage report --fail-under=75cd frontend && npm run lint && npx tsc --noEmit && npm run buildFEATURE_PROMO_CLASSIFICATION=false, checkbox is hidden on bothRecordEntryandOcrQueue; PATCHingisPromotionalis a no-op; confirm creates mail without the field.FEATURE_PROMO_CLASSIFICATION=true, checkbox appears on both screens; toggling on the OCR review persists across navigation; confirmed mail doc hasisPromotional: true./api/feature-flagspopulates all five flags in the Zustand store.Closes #90