cursor.execute(f'''SELECT country_code, COUNT(*) FROM dashboard_events WHERE {where_sql} GROUP BY country_code ORDER BY COUNT(*) DESC LIMIT 20''',tuple(params))
cursor.execute(f'''SELECT username, user_id, COUNT(*) FROM dashboard_events WHERE {where_sql} GROUP BY username, user_id ORDER BY COUNT(*) DESC LIMIT 20''',tuple(params))
<pstyle="font-size: 28px; font-weight: bold;">${{ "%.2f"|format((optimization_savings.free_tier_equivalent_savings.cost_saved if optimization_savings else 0) or 0) }}</p>
</div>
</div>
<pstyle="color: var(--color-muted); margin-top: -6px; margin-bottom: 18px;">The combined estimate includes direct execution savings from response caching and batching plus free-tier/subscription-equivalent avoided cost estimates.</p>
{% else %}
<pstyle="color: var(--color-muted);">No optimization savings recorded yet. Increase usage on providers with known upstream free tiers, or enable deduplication, condensation, batching, or caching to see savings.</p>
The table below only uses explicitly configured provider free-tier limits. Generic defaults are excluded to avoid overstated savings on subscription or bundled plans.
Extra free-tier equivalents are counted only for complete additional quota blocks beyond the first included tier within the selected period.
</p>
<table>
<tr>
<th>Provider</th>
<th>Used Tokens</th>
<th>Requests</th>
<th>Measured Usage</th>
<th>Free Limit</th>
<th>Extra Free Tiers</th>
<th>Equivalent Saved Tokens</th>
<th>Premium Reference</th>
<th>Equivalent Saved Cost</th>
</tr>
{% for item in optimization_savings.provider_equivalents %}
<pstyle="color: var(--color-muted);">No optimization savings recorded yet. Increase usage on providers with known upstream free tiers, or enable deduplication, condensation, batching, or caching to see savings.</p>
?'Delete all analytics for global (non-user) providers/models? This cannot be undone.'
:'Delete ALL analytics including all user data? This cannot be undone.';
constmsg=scope==='global'?'Delete all analytics for global (non-user) providers/models? This cannot be undone.':'Delete ALL analytics including all user data? This cannot be undone.';
if(!confirm(msg))return;
if(!confirm('Are you sure? This is irreversible.'))return;