fix: opti
This commit is contained in:
parent
d6bd2308a1
commit
e4da0f59b3
1 changed files with 13 additions and 12 deletions
|
@ -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
|
let sentOnce = false
|
||||||
|
|
||||||
await async.allLimit(devices, MAX_PARALLEL_PUSHES, async (device) => {
|
await async.allLimit(devices, MAX_PARALLEL_PUSHES, async (device) => {
|
||||||
const { id: deviceId, fcmToken } = device
|
const { id: deviceId, fcmToken } = device
|
||||||
const notificationAlertLevel = device.notificationAlertLevel || "green"
|
const notificationAlertLevel = device.notificationAlertLevel || "green"
|
||||||
|
@ -176,18 +189,6 @@ module.exports = async function () {
|
||||||
"Found device record"
|
"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) {
|
if (alertUserId === alertingUserId) {
|
||||||
logger.info(
|
logger.info(
|
||||||
{ alertUserId, alertingUserId },
|
{ alertUserId, alertingUserId },
|
||||||
|
|
Loading…
Add table
Reference in a new issue