From 927116d5414873d15584649da0368575f952f862 Mon Sep 17 00:00:00 2001 From: Hsu Zhong Jun <27919917+dcshzj@users.noreply.github.com> Date: Mon, 31 Oct 2022 11:56:29 +0800 Subject: [PATCH] fix: use upsert for updateReviewRequestLastViewedAt --- src/services/review/ReviewRequestService.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/services/review/ReviewRequestService.ts b/src/services/review/ReviewRequestService.ts index e30cb93c6..78a767e07 100644 --- a/src/services/review/ReviewRequestService.ts +++ b/src/services/review/ReviewRequestService.ts @@ -285,18 +285,12 @@ export default class ReviewRequestService { const { isomerUserId: userId } = sessionData const { id: reviewRequestId } = reviewRequest - await this.reviewRequestView.update( - { - lastViewedAt: new Date(), - }, - { - where: { - reviewRequestId, - siteId: site.id, - userId, - }, - } - ) + await this.reviewRequestView.upsert({ + reviewRequestId, + siteId: site.id, + userId, + lastViewedAt: new Date(), + }) } markReviewRequestAsViewed = async (