260401_02_ENH: 브랜드의 gap 부분 2개 연도 나올수 있도록 수정

This commit is contained in:
2026-04-01 09:49:17 +09:00
parent ebc72e57c2
commit 3a42ac867c

View File

@@ -68,26 +68,31 @@ const CategoryPage = () => {
const years = Array.from(new Set(rows.map((row) => Number(row.year)))) const years = Array.from(new Set(rows.map((row) => Number(row.year))))
.filter((year) => Number.isFinite(year)) .filter((year) => Number.isFinite(year))
.sort((a, b) => b - a) .sort((a, b) => b - a)
.slice(0, 2); .slice(0, -1);
if (years.length < 2) { if(years.length === 0) {
nextMap[f.requestKeyResolved] = rows; nextMap[f.requestKeyResolved] = rows;
return; return;
} }
const [currentYear, prevYear] = years; const gapRowsByYear = new Map<number, BannerRow>();
years.forEach((year) => {
const currentYear = year;
const prevYear = year - 1;
const gapRow = buildGapRow(rows, prevYear, currentYear, "LG"); const gapRow = buildGapRow(rows, prevYear, currentYear, "LG");
if (!gapRow) { if(gapRow !== null){
nextMap[f.requestKeyResolved] = rows; gapRowsByYear.set(currentYear, gapRow);
return;
} }
});
const nextRows: BannerRow[] = []; const nextRows: BannerRow[] = [];
rows.forEach((row) => { rows.forEach((row) => {
nextRows.push(row); nextRows.push(row);
if (Number(row.year) === currentYear && row.rowLabel === "LG") { const gapRow = gapRowsByYear.get(Number(row.year));
if (row.rowLabel === "LG" && gapRow) {
nextRows.push(gapRow); nextRows.push(gapRow);
} }
}); });