Skip to content

Bulk categorization: background worker + quicker calibration #96

Description

@antonio-ivanovski

Problem

Bulk categorization is synchronous with all state in browser / in-process memory (calibratepreviewbulkUpdateCategories). Long AI calls block the user, are lost on reload/timeout, and hold state only in memory.

Decisions

  • Trigger: Manual only — admin clicks "Categorize all" to enqueue job. No cron/auto.
  • Naive pre-pass: Suggest only, no auto-apply.
  • Completion: Notification → dedicated review/merge UI.
  • Sync path: Removed entirely. No fallback wizard; all bulk work via persisted background job.

Proposal

1. Quicker calibration

  • Run existing naive suggestCategoryFromTitle (dictionary + naive search on samples) before AI to pre-fill obvious suggestions instantly in calibration.
  • Use smaller AI batches with fewer samples per round for faster feedback / fewer tokens. Naive suggestions are suggest-only — user still confirms.

2. Async bulk categorization

  • Replace in-process flow with pg-boss background job. Enqueued manually per group, processes eligible general expenses in batches with server-persisted state (retriable, survives reload).
  • Job never auto-writes. On completion it notifies user and exposes result for review.

UX (high-level)

  1. Admin opens Bulk Categorize → sees naive suggestions instantly on sample, calibrates few rows if needed.
  2. Clicks "Categorize all" → job enqueued, wizard closes. Group shows "Categorization running in background" state.
  3. On completion: in-app (+ email per preferences) notification → links to dedicated review page (list: current vs suggested, edit/exclude per row, bulk accept) → explicit Confirm to call bulkUpdateCategories.

Out of scope

Job schema, batch sizing, retry/backoff, concurrency limits — to be decided in implementation.

Acceptance

  • Calibration uses naive pre-pass as suggest-only
  • Smaller AI batches
  • Manual-only background batched job with DB-persisted state, in-process state removed
  • Notification + dedicated merge/review UI before apply

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions