greptile review fixes

This commit is contained in:
x032205
2025-10-08 23:58:38 -04:00
parent c6696d4fde
commit e752391dbf
5 changed files with 24 additions and 18 deletions
@@ -30,8 +30,7 @@ export const gatewayV2DalFactory = (db: TDbClient) => {
.select(db.ref("name").withSchema(TableName.Identity).as("identityName"));
if (isHeartbeatStale) {
const oneHourAgo = new Date();
oneHourAgo.setHours(oneHourAgo.getHours() - 1);
const oneHourAgo = new Date(Date.now() - 60 * 60 * 1000);
void query.where(`${TableName.GatewayV2}.heartbeat`, "<", oneHourAgo);
void query.where((v) => {
void v
@@ -902,8 +902,6 @@ export const gatewayV2ServiceFactory = ({
"Found gateways with last heartbeat over an hour ago. Sending notifications."
);
await Promise.all(unhealthyGateways.map((gw) => gatewayV2DAL.updateById(gw.id, { healthAlertedAt: new Date() })));
const gatewaysByOrg = unhealthyGateways.reduce<Record<string, (typeof unhealthyGateways)[number][]>>((acc, gw) => {
if (!acc[gw.orgId]) {
acc[gw.orgId] = [];
@@ -944,6 +942,8 @@ export const gatewayV2ServiceFactory = ({
},
template: SmtpTemplates.HealthAlert
});
await Promise.all(gateways.map((gw) => gatewayV2DAL.updateById(gw.id, { healthAlertedAt: new Date() })));
} catch (error) {
logger.error(error, `Failed to send gateway health notifications for organization [orgId=${orgId}]`);
}