Skip to content

Commit

Permalink
actually add the script oops
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanniser committed Oct 21, 2024
1 parent 36eec2e commit aad5453
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions scripts/addImagesToProducts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ const main = Effect.gen(function* () {
`Products without image urls found: ${productsWithoutImage.length}`,
);

// yield* Effect.all(
// productsWithoutImage.map((product, i) =>
// Effect.gen(function* () {
// yield* Effect.log(
// `Beginning update for index ${i} of ${productsWithoutImage.length}`,
// );
// const randomImageUrl = yield* Random.choice(allUrls);
// yield* Effect.tryPromise(() =>
// db
// .update(products)
// .set({ image_url: randomImageUrl })
// .where(eq(products.slug, product.slug)),
// );
// }),
// ),
// { mode: "either", concurrency: 10 },
// );
yield* Effect.all(
productsWithoutImage.map((product, i) =>
Effect.gen(function* () {
yield* Effect.log(
`Beginning update for index ${i} of ${productsWithoutImage.length}`,
);
const randomImageUrl = yield* Random.choice(allUrls);
yield* Effect.tryPromise(() =>
db
.update(products)
.set({ image_url: randomImageUrl })
.where(eq(products.slug, product.slug)),
);
}),
),
{ mode: "either", concurrency: 10 },
);
});

NodeRuntime.runMain(main);

0 comments on commit aad5453

Please sign in to comment.