fix: use metrics provider pattern for merchant dashboard stats

The merchant dashboard was showing subscription count as "Total Stores".
Add get_merchant_metrics() to MetricsProviderProtocol and implement it
in tenancy, billing, and customer providers. Dashboard now fetches real
stats from a new /merchants/core/dashboard/stats endpoint and displays
4 cards: active subscriptions, total stores, customers, team members.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-22 21:28:59 +01:00
parent 42b894094a
commit ff852f1ab3
9 changed files with 372 additions and 15 deletions

View File

@@ -207,6 +207,28 @@ class MetricsProviderProtocol(Protocol):
"""
...
def get_merchant_metrics(
self,
db: "Session",
merchant_id: int,
context: MetricsContext | None = None,
) -> list[MetricValue]:
"""
Get metrics scoped to a specific merchant.
Called by the merchant dashboard to display merchant-scoped statistics.
Should only include data belonging to the specified merchant.
Args:
db: Database session for queries
merchant_id: ID of the merchant to get metrics for
context: Optional filtering/scoping context
Returns:
List of MetricValue objects for this merchant
"""
...
__all__ = [
"MetricValue",