mirror of
https://github.com/AJaySi/ALwrity.git
synced 2026-04-26 01:15:52 +03:00
[PR #376] [MERGED] Fix billing-period key drift and fully reset provider counters (including audio) #679
Labels
No labels
AI Content Agents
AI Content Strategy
AI Content planning
AI Marketing Tools
AI SEO
AI personalization
AI writer
ALwrity Copi-lot
Alwrity web search
Anthropic
DeepSeek
Gemini AI
Integration
LLM
OnBoarding
OnBoarding
RAG knowledgebase Memory
bug
documentation
enhancement
good first issue
help wanted
invalid
openai
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ALwrity#679
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/AJaySi/ALwrity/pull/376
Author: @AJaySi
Created: 3/4/2026
Status: ✅ Merged
Merged: 3/5/2026
Merged by: @AJaySi
Base:
main← Head:codex/update-reset_current_billing_period-logic📝 Commits (1)
cf4c08fAlign usage period keys with subscription window and reset audio counters📊 Changes
1 file changed (+54 additions, -10 deletions)
View changed files
📝
backend/services/subscription/usage_tracking_service.py(+54 -10)📄 Description
Motivation
UserSubscription.current_period_start/current_period_endinstead of relying on a calendar month string alone.reset_current_billing_periodclears every tracked provider counter/cost so renewed plans start from a true zero state.Description
def _get_authoritative_billing_period_keys(user_id, billing_period=None)to resolve canonicalbilling_period,lookup_periods, and subscription boundary metadata, with explicit-period and fallback behavior.datetime.now().strftime("%Y-%m")/get_current_billing_periodusage with the helper intrack_api_usage,_update_usage_summary,_check_usage_alerts, andget_user_usage_statsso reads and writes uselookup_periodsand the canonical period consistently.reset_current_billing_periodto resolve the reset target from the subscription window (using the helper andbilling_period.in_(lookup_periods)) and expanded reset coverage to include all tracked counters/costs such asaudio_calls,audio_cost, andexa_calls.get_user_usage_statsto preserve an explicitly requested period (requested_billing_period) while still using the authoritative lookup keys for DB queries and initialization.Testing
python -m py_compile backend/services/subscription/usage_tracking_service.pyand the module compiled successfully.Codex Task
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.