take out the buggy and damaging auto-delete duplicate feature

This commit is contained in:
adueck 2023-12-18 23:45:34 +04:00
parent 5a90557ebb
commit 4ef73f793e
1 changed files with 16 additions and 16 deletions

View File

@ -107,30 +107,30 @@ async function getRows() {
async function getRawEntries(): Promise<T.DictionaryEntry[]> { async function getRawEntries(): Promise<T.DictionaryEntry[]> {
const rows = await getRows(); const rows = await getRows();
async function deleteRow(i: number) { // async function deleteRow(i: number) {
console.log("WILL DELETE ROW", rows[i].p, rows[i].ts, rows[i].f); // console.log("WILL NOT DELETE ROW", rows[i].p, rows[i].ts, rows[i].f);
await rows[i].delete(); // // await rows[i].delete();
} // }
const entries: T.DictionaryEntry[] = []; const entries: T.DictionaryEntry[] = [];
let sheetIndex = 0; let sheetIndex = 0;
// get the rows in order of ts for easy detection of duplicate entries // get the rows in order of ts for easy detection of duplicate entries
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
function sameEntry(a: any, b: any): boolean { // function sameEntry(a: any, b: any): boolean {
return a.p === b.p && a.f === b.f && a.e === b.e; // return a.p === b.p && a.f === b.f && a.e === b.e;
} // }
sheetIndex++; sheetIndex++;
const row = rows[i]; const row = rows[i];
const nextRow = rows[i + 1] || undefined; const nextRow = rows[i + 1] || undefined;
if (row.ts === nextRow?.ts) { if (row.ts === nextRow?.ts) {
if (sameEntry(row, nextRow)) { // if (sameEntry(row, nextRow)) {
// this looks like a duplicate entry made by the sheets api // // this looks like a duplicate entry made by the sheets api
// delete it and keep going // // delete it and keep going
await deleteRow(sheetIndex); // await deleteRow(sheetIndex);
sheetIndex--; // sheetIndex--;
continue; // continue;
} else { // } else {
throw new Error(`ts ${row.ts} is a duplicate ts of a different entry`); throw new Error(`ts ${row.ts} is a duplicate ts of a different entry`);
} // }
} }
const e: T.DictionaryEntry = { const e: T.DictionaryEntry = {
i: 1, i: 1,