From 2db956d5a7ed39b4f10721c541526458d6988ccf Mon Sep 17 00:00:00 2001 From: adueck Date: Tue, 23 Apr 2024 16:51:43 +0400 Subject: [PATCH] get all duplicates --- functions/src/publish.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/functions/src/publish.ts b/functions/src/publish.ts index 92b090d..7e89934 100644 --- a/functions/src/publish.ts +++ b/functions/src/publish.ts @@ -114,6 +114,7 @@ async function getRawEntries(): Promise { const entries: T.DictionaryEntry[] = []; // let sheetIndex = 0; // get the rows in order of ts for easy detection of duplicate entries + const duplicates: Set = new Set(); for (let i = 0; i < rows.length; i++) { // function sameEntry(a: any, b: any): boolean { // return a.p === b.p && a.f === b.f && a.e === b.e; @@ -129,9 +130,16 @@ async function getRawEntries(): Promise { // sheetIndex--; // continue; // } else { - throw new Error(`ts ${row.ts} is a duplicate ts of a different entry`); + duplicates.add(row.ts); // } } + if (duplicates.size) { + throw new Error( + `ts ${Array.from(duplicates).join( + ", " + )} is a duplicate ts of a different entry` + ); + } const e: T.DictionaryEntry = { i: 1, ts: parseInt(row.ts),