update product analytic

This commit is contained in:
efrilm
2025-10-07 00:02:15 +07:00
parent f55ea1ceb0
commit 27a2535dde
6 changed files with 7 additions and 1 deletions
+2 -1
View File
@@ -113,6 +113,7 @@ func (r *AnalyticsRepositoryImpl) GetProductAnalytics(ctx context.Context, organ
p.name as product_name,
c.id as category_id,
c.name as category_name,
c.order as category_order,
COALESCE(SUM(oi.quantity), 0) as quantity_sold,
COALESCE(SUM(oi.total_price), 0) as revenue,
CASE
@@ -133,7 +134,7 @@ func (r *AnalyticsRepositoryImpl) GetProductAnalytics(ctx context.Context, organ
}
err := query.
Group("p.id, p.name, c.id, c.name").
Group("p.id, p.name, c.id, c.name, c.order").
Order("revenue DESC").
Limit(limit).
Scan(&results).Error