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:
@@ -221,6 +221,23 @@ class StoreDashboardStatsResponse(BaseModel):
|
||||
revenue: StoreRevenueStats
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Merchant Dashboard Statistics
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class MerchantDashboardStatsResponse(BaseModel):
|
||||
"""Merchant dashboard statistics response schema.
|
||||
|
||||
Used by: GET /api/v1/merchants/core/dashboard/stats
|
||||
"""
|
||||
|
||||
active_subscriptions: int = Field(0, description="Active or trial subscriptions")
|
||||
total_stores: int = Field(0, description="Total stores owned by this merchant")
|
||||
total_customers: int = Field(0, description="Total customers across all stores")
|
||||
team_members: int = Field(0, description="Distinct active team members across stores")
|
||||
|
||||
|
||||
__all__ = [
|
||||
# Stats responses
|
||||
"StatsResponse",
|
||||
@@ -240,4 +257,6 @@ __all__ = [
|
||||
"StoreRevenueStats",
|
||||
"StoreInfo",
|
||||
"StoreDashboardStatsResponse",
|
||||
# Merchant dashboard
|
||||
"MerchantDashboardStatsResponse",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user