Auto: refactor/simplify-daily-limits #18

Merged
claude-bot merged 1 commit from refactor/simplify-daily-limits into main 2026-03-01 17:08:17 -07:00
Collaborator

Automated PR for branch refactor/simplify-daily-limits.

Automated PR for branch `refactor/simplify-daily-limits`.
refactor: simplify limits to daily output message count
All checks were successful
Auto PR Review / review (push) Successful in 3m13s
8b3d52bd2e
Replace 3 overlapping limit layers (subscription tiers, daily tokens,
monthly system budget) with a single daily output message limit
(free: 10/day, premium: 30/day). Count by Telegram output messages —
a translation that splits into 2 messages counts as 2.

- Add output_messages column to api_token_usage table
- Add get_user_daily_output_messages() query function
- Simplify TranslationDeps to translate + log_error only
- Remove TokenBudgetManager, ensure_free_user_sub, quota functions
- Update all handlers and tests for new limit system (-686 lines net)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
Collaborator

Approved

Clean, well-executed refactoring that replaces a complex quota-based rate limiting system (reserve/refund per-subscription translation counts + monthly token budgets) with a simpler daily output message count model. The changes are consistent across all layers: constants, database, handlers, strings, and tests. No bugs or critical issues found. All format string placeholders match their call sites. Removed code paths (decrement/increment/refund, TokenBudgetManager, ensure_free_user_subscription) are fully cleaned up with no dangling references. Tests are updated to match the new model including a new multi-message output counting test.

Suggestions

  • config.py: REVENUE_PER_TRANSLATION is now computed as revenue per daily message (denominator changed from 50 to 900). The variable name still says "per translation" — consider renaming to REVENUE_PER_MESSAGE for clarity.
  • strings.py: PAYMENT_TRANSLATIONS_FORMAT is now used for daily messages ("kuniga {count} ta xabar") but the constant name still references "translations". Consider renaming to PAYMENT_MESSAGES_FORMAT.
  • strings.py: The removed DAILY_MESSAGE_LIMIT_FREE and DAILY_MESSAGE_LIMIT_PREMIUM strings defined in strings.py (lines 22-37) appear to be unused — they were added in this diff but never referenced by any handler. If they're intended for future use, that's fine; otherwise they're dead code.
## Approved Clean, well-executed refactoring that replaces a complex quota-based rate limiting system (reserve/refund per-subscription translation counts + monthly token budgets) with a simpler daily output message count model. The changes are consistent across all layers: constants, database, handlers, strings, and tests. No bugs or critical issues found. All format string placeholders match their call sites. Removed code paths (decrement/increment/refund, TokenBudgetManager, ensure_free_user_subscription) are fully cleaned up with no dangling references. Tests are updated to match the new model including a new multi-message output counting test. ### Suggestions - **config.py**: REVENUE_PER_TRANSLATION is now computed as revenue per daily message (denominator changed from 50 to 900). The variable name still says "per translation" — consider renaming to REVENUE_PER_MESSAGE for clarity. - **strings.py**: PAYMENT_TRANSLATIONS_FORMAT is now used for daily messages ("kuniga {count} ta xabar") but the constant name still references "translations". Consider renaming to PAYMENT_MESSAGES_FORMAT. - **strings.py**: The removed DAILY_MESSAGE_LIMIT_FREE and DAILY_MESSAGE_LIMIT_PREMIUM strings defined in strings.py (lines 22-37) appear to be unused — they were added in this diff but never referenced by any handler. If they're intended for future use, that's fine; otherwise they're dead code.
claude-bot deleted branch refactor/simplify-daily-limits 2026-03-01 17:08:17 -07:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bittabola/tarjimon!18
No description provided.