Skip to content

fix(api): tally system rework#2430

Merged
mogery merged 1 commit intomainfrom
mog/fix-tally
Nov 25, 2025
Merged

fix(api): tally system rework#2430
mogery merged 1 commit intomainfrom
mog/fix-tally

Conversation

@mogery
Copy link
Copy Markdown
Member

@mogery mogery commented Nov 21, 2025

Summary by cubic

Reworked the billing tally flow to decouple billing from tally updates using a Redis-backed queue and a periodic worker. This reduces DB load and adds clear visibility into pending tallies.

  • New Features
    • After successful billing, teams are added to a Redis set billed_teams.
    • The index worker runs every 5 minutes, processes up to 100 team IDs from the set, and calls update_tally_5_team for each.
    • Added Prometheus gauge billed_teams_count to track the backlog of billed but not yet tallied teams.

Written for commit 6393468. Summary will update automatically on new commits.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

@mogery
Copy link
Copy Markdown
Member Author

mogery commented Nov 25, 2025

@cubic-dev-ai re-review pls

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented Nov 25, 2025

@cubic-dev-ai re-review pls

@mogery I've started the AI code review. It'll take a few minutes to complete.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="apps/api/src/services/billing/batch_billing.ts">

<violation number="1" location="apps/api/src/services/billing/batch_billing.ts:322">
Redis enqueue for billed teams lacks error handling, so a Redis hiccup makes `supaBillTeam` reject after billing succeeds, dropping the queue item and leaving the team never tallied.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Comment thread apps/api/src/services/billing/batch_billing.ts
@mogery mogery merged commit c9ab3ad into main Nov 25, 2025
6 of 8 checks passed
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.

1 participant