Skip to content

Commit 0e5ec6f

Browse files
Update components/trustpilot/sources/new-product-reviews/new-product-reviews.mjs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 2b77612 commit 0e5ec6f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

components/trustpilot/sources/new-product-reviews/new-product-reviews.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ export default {
6464
}
6565

6666
// Filter for new reviews since last poll (client-side filtering)
67-
let newReviews = reviews;
68-
if (lastReviewTime) {
69-
newReviews = reviews.filter((review) =>
70-
new Date(review.createdAt).getTime() > new Date(lastReviewTime).getTime());
71-
}
67+
const lastTs = Number(lastReviewTime) || 0;
68+
const toMs = (d) => new Date(d).getTime();
69+
let newReviews = lastTs
70+
? reviews.filter((r) => toMs(r.createdAt) > lastTs)
71+
: reviews;
7272

7373
if (!newReviews.length) {
7474
console.log("No new product reviews since last poll");

0 commit comments

Comments
 (0)