Skip to content

feat(subscription): add five-hour usage limits#3992

Open
paraliine wants to merge 1 commit into
Wei-Shaw:mainfrom
paraliine:feat/api-key-five-hour-quota
Open

feat(subscription): add five-hour usage limits#3992
paraliine wants to merge 1 commit into
Wei-Shaw:mainfrom
paraliine:feat/api-key-five-hour-quota

Conversation

@paraliine

Copy link
Copy Markdown
Contributor

Related Issue

Closes #3416

Summary

This PR adds an independent rolling five-hour usage limit to the subscription system.

Changes

  • Allow administrators to configure a five-hour USD limit for subscription groups
  • Track five-hour usage and window start time for each user subscription
  • Enforce the limit during API key authentication and billing
  • Accumulate five-hour usage alongside daily, weekly, and monthly usage
  • Support manual five-hour quota resets
  • Display five-hour usage and reset time in the admin and user interfaces
  • Add English and Chinese translations for the new quota fields

The five-hour window starts when the subscription is first used and resets on a rolling five-hour cycle.

Database Changes

Add an optional field to subscription groups:

  • five_hour_limit_usd

Add the following fields to user subscriptions:

  • five_hour_usage_usd
  • five_hour_window_start

Existing subscription groups remain unlimited for the five-hour dimension unless a limit is explicitly configured.

Compatibility

  • The five-hour limit is optional and opt-in
  • Existing subscription groups retain their current behavior
  • API changes are additive
  • No existing quota fields or reset behavior are removed

Validation

  • Backend unit tests:
    • go test -tags=unit ./internal/service ./internal/repository ./internal/server/...
  • Frontend type checking
  • Frontend ESLint checks

Add configurable rolling five-hour limits for subscription groups, track and enforce per-subscription usage windows, and expose the new quota through APIs and admin/user interfaces. Addresses Wei-Shaw#3416.
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.

[feature] 支持订阅 5 小时用量限额

1 participant