58faf9eaec
- Add /cabinet/admin/stats/sales/* endpoints: summary, trials,
subscriptions, renewals, addons, deposits
- Period params: days preset or custom start_date/end_date range
- MAX_PERIOD_DAYS=730 validation with proper date parsing
- Conversion rate capped at 100% to handle cross-period conversions
- Use EXTRACT(epoch)/86400 for accurate interval day calculation
- Consolidated subscription queries with CASE expressions
- Renewals with period-over-period comparison and trend detection
- Permission-gated with require_permission('stats:read')
- Shared link utilities in cabinet/utils/links.py
20 lines
664 B
Python
20 lines
664 B
Python
"""Shared utility for generating campaign deep links and web links."""
|
|
|
|
from app.config import settings
|
|
|
|
|
|
def get_campaign_deep_link(start_parameter: str) -> str:
|
|
"""Generate a Telegram deep link for a campaign."""
|
|
bot_username = settings.get_bot_username()
|
|
if bot_username:
|
|
return f'https://t.me/{bot_username}?start={start_parameter}'
|
|
return f'?start={start_parameter}'
|
|
|
|
|
|
def get_campaign_web_link(start_parameter: str) -> str | None:
|
|
"""Generate a web app link for a campaign."""
|
|
base_url = (settings.MINIAPP_CUSTOM_URL or '').rstrip('/')
|
|
if base_url:
|
|
return f'{base_url}/?campaign={start_parameter}'
|
|
return None
|