Skip to content

Commit

Permalink
revert iter changes on copy sheets script (#5231)
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinemodic authored Aug 7, 2024
1 parent e380ed4 commit b3e550b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/scan/backend/scripts/copy_sheets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@ function copySheets({ targetSheetCount }: CopySheetsInput): void {
500 // A cap to limit how much data the script loads
);

const newSheetIds = iter(store.forEachAcceptedSheet())
const sheets = iter(store.forEachAcceptedSheet())
.take(maxNumSheetsToReadForCopying)
.cycle()
.take(numSheetsToCreate)
.map((sheet) => copySheet(store, sheet))
.toArray();

const newSheetIds: string[] = [];
for (let i = 0; i < numSheetsToCreate; i += 1) {
const sheet = sheets[i % sheets.length];
const newSheetId = copySheet(store, sheet);
newSheetIds.push(newSheetId);
}

const sheetOrSheets = numSheetsToCreate === 1 ? 'sheet' : 'sheets';
console.log(
`✅ Created ${numSheetsToCreate} new ${sheetOrSheets} by copying existing sheets, ` +
Expand Down

0 comments on commit b3e550b

Please sign in to comment.