This commit is contained in:
KM Koushik
2025-08-23 20:46:11 +10:00
committed by GitHub
parent a895db751f
commit 060165b449

View File

@@ -205,6 +205,7 @@ export async function parseSesHook(data: SesEvent) {
updateField === "delivered" updateField === "delivered"
) { ) {
logger.info("Updating cumulated metrics"); logger.info("Updating cumulated metrics");
const cumulatedField = isHardBounced ? "hardBounced" : updateField;
await db.cumulatedMetrics.upsert({ await db.cumulatedMetrics.upsert({
where: { where: {
teamId_domainId: { teamId_domainId: {
@@ -213,14 +214,14 @@ export async function parseSesHook(data: SesEvent) {
}, },
}, },
update: { update: {
[updateField]: { [cumulatedField]: {
increment: BigInt(1), increment: BigInt(1),
}, },
}, },
create: { create: {
teamId: email.teamId, teamId: email.teamId,
domainId: email.domainId ?? 0, domainId: email.domainId ?? 0,
[updateField]: BigInt(1), [cumulatedField]: BigInt(1),
}, },
}); });
} }