fix: opti

This commit is contained in:
Jo 2025-08-24 11:53:15 +02:00
parent d6bd2308a1
commit e4da0f59b3
Signed by: devthejo
GPG key ID: 00CCA7A92B1D5351

View file

@ -167,7 +167,20 @@ module.exports = async function () {
}
}
logger.debug({ alertId }, "Querying alert record")
const [{ userId: alertUserId, level, code }] = await sql`
SELECT
"alert"."level" as "level",
"alert"."user_id" as "userId",
"alert"."code" as "code"
FROM
"alert"
WHERE
"alert"."id" = ${alertId}
`
let sentOnce = false
await async.allLimit(devices, MAX_PARALLEL_PUSHES, async (device) => {
const { id: deviceId, fcmToken } = device
const notificationAlertLevel = device.notificationAlertLevel || "green"
@ -176,18 +189,6 @@ module.exports = async function () {
"Found device record"
)
logger.debug({ alertId }, "Querying alert record")
const [{ userId: alertUserId, level, code }] = await sql`
SELECT
"alert"."level" as "level",
"alert"."user_id" as "userId",
"alert"."code" as "code"
FROM
"alert"
WHERE
"alert"."id" = ${alertId}
`
if (alertUserId === alertingUserId) {
logger.info(
{ alertUserId, alertingUserId },