Skip to content

Commit

Permalink
Speed up computation
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Dec 12, 2023
1 parent 7ca2d8e commit 8ca438f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export const updater = async () => {
const result = await db.collection("cars").insertMany(parsedData);
console.log(`${result.insertedCount} document(s) inserted`);
} else {
const existingDataMap = new Map(
existingData.map((item) => [item.month, item]),
);
const newDataToInsert = parsedData.filter(
(newItem) =>
!existingData.some(
(existingItem) => existingItem.month === newItem.month,
),
(newItem) => !existingDataMap.has(newItem.month),
);

if (newDataToInsert.length > 0) {
Expand Down

0 comments on commit 8ca438f

Please sign in to comment.