fix: resolve maximum call stack size exceeded error and optimize master table

This commit is contained in:
Christian Vidal Wolf
2026-03-16 13:19:21 +01:00
parent 845a8e0ae6
commit b304e0ddb8
3 changed files with 22 additions and 17 deletions
+5 -2
View File
@@ -2461,9 +2461,12 @@ export const calculateVelocityMap = (data: SalesRecord[]): Map<string, number> =
const validYears = data.map(r => r.year).filter(y => y > 0);
if (validYears.length === 0) return new Map();
const latestYear = Math.max(...validYears);
const latestYear = validYears.reduce((a, b) => Math.max(a, b), 0);
const yearData = data.filter(r => r.year === latestYear);
const latestWeek = yearData.length > 0 ? Math.max(...yearData.map(r => r.week).filter(w => w !== undefined) as number[]) : 0;
const latestWeek = yearData.length > 0
? (yearData.map(r => r.week).filter(w => w !== undefined) as number[])
.reduce((a, b) => Math.max(a, b), 0)
: 0;
const last4WeeksKeys = new Set<string>();
for (let i = 0; i < 4; i++) {