Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
aff994bd05
commit
0be9d7a595
@@ -125,22 +125,29 @@ export async function matchAndUpdateEmails(emailIds: string[]): Promise<{
|
||||
lookups.priorEmails,
|
||||
);
|
||||
|
||||
const update: Record<string, unknown> = {
|
||||
const baseUpdate = {
|
||||
match_status: result.status,
|
||||
match_suggestions: result.suggestions,
|
||||
match_suggestions: result.suggestions as unknown as never,
|
||||
match_reason: result.reason,
|
||||
};
|
||||
if (result.status === "matched" && result.case_id) {
|
||||
update.case_id = result.case_id;
|
||||
update.matched_at = new Date().toISOString();
|
||||
matched++;
|
||||
} else if (result.status === "suggested") {
|
||||
suggested++;
|
||||
await supabaseAdmin
|
||||
.from("incoming_emails")
|
||||
.update({
|
||||
...baseUpdate,
|
||||
case_id: result.case_id,
|
||||
matched_at: new Date().toISOString(),
|
||||
})
|
||||
.eq("id", row.id);
|
||||
} else {
|
||||
unmatched++;
|
||||
if (result.status === "suggested") suggested++;
|
||||
else unmatched++;
|
||||
await supabaseAdmin
|
||||
.from("incoming_emails")
|
||||
.update(baseUpdate)
|
||||
.eq("id", row.id);
|
||||
}
|
||||
|
||||
await supabaseAdmin.from("incoming_emails").update(update).eq("id", row.id);
|
||||
}
|
||||
|
||||
return { matched, suggested, unmatched };
|
||||
|
||||
Reference in New Issue
Block a user