- Fix text selection menu not showing: wire contentRef via inputRef on multiline TextField - Fix blog title not truncating: add min-w-0 for flex item overflow - Fix outline generation 500: escape curly braces in f-string prompt template - Fix content generation 'NoneType not callable': replace SessionLocal() with get_session_for_user(), add db param to MediumBlogGenerator, fix signature mismatch in database_task_manager - Fix writing assistant suggest 500: add auth + user_id to API endpoint and service, replace sync requests with httpx.AsyncClient - Fix hallucination detector 404: explicitly include router in main.py and app.py - Fix missing error_data in task failure responses - Hide CopilotKit web inspector button - Remove hardcoded fallback suggestions from SmartTypingAssist - Fix stale closure refs in SmartTypingAssist handleTypingChange - Add two-column editor layout, stats bar, section hover menu - Various subscription, billing, and research module improvements
19 lines
758 B
Python
19 lines
758 B
Python
"""
|
|
Usage trends functions.
|
|
Extracted from usage_tracking_service.py for better maintainability.
|
|
"""
|
|
|
|
from typing import Dict, Any
|
|
from sqlalchemy.orm import Session
|
|
from loguru import logger
|
|
|
|
|
|
def get_usage_trends(user_id: str, months: int, db: Session) -> Dict[str, Any]:
|
|
"""Get usage trends over time with self-healing from logs."""
|
|
from services.subscription.usage_tracking_helpers import build_billing_periods, query_usage_summaries, self_heal_summaries_from_logs, build_usage_trends_response
|
|
|
|
periods = build_billing_periods(months)
|
|
summary_dict = query_usage_summaries(db, user_id, periods)
|
|
self_heal_summaries_from_logs(db, user_id, periods, summary_dict)
|
|
return build_usage_trends_response(periods, summary_dict)
|