mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 13:25:23 +02:00
feat: add Glance Views (GV) to Weekly Sales grid
- Updated WeeklyPivotRow interface and pivotWeeklySalesData to aggregate GV data per week. - Modified WeeklyGrid.tsx to display GV next to Spend in total header and individual rows. - Added GV sorting support in the Weekly Sales grid.
This commit is contained in:
@@ -1437,6 +1437,7 @@ export interface WeeklyPivotRow {
|
||||
customer: string;
|
||||
unitsByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
|
||||
spendByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
|
||||
gvByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
|
||||
}
|
||||
|
||||
export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
|
||||
@@ -1469,7 +1470,8 @@ export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
|
||||
line: record.line || '',
|
||||
customer: record.customer || record.marketplace || '',
|
||||
unitsByWeek: {},
|
||||
spendByWeek: {}
|
||||
spendByWeek: {},
|
||||
gvByWeek: {}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1480,6 +1482,7 @@ export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
|
||||
// Only add cost if we haven't already added it for this ASIN/week
|
||||
// Since mergeSalesAndAdsData now outputs one record per ASIN/week, this should be clean
|
||||
row.spendByWeek[weekKey] = (row.spendByWeek[weekKey] || 0) + (record.cost || 0);
|
||||
row.gvByWeek[weekKey] = (row.gvByWeek[weekKey] || 0) + (record.glanceViews || 0);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user