chore: server code formatting

This commit is contained in:
Rafael Taranto 2025-05-12 15:35:00 +01:00
parent aedabcbdee
commit 68517170e2
234 changed files with 9824 additions and 6195 deletions

View file

@ -15,18 +15,22 @@ compliance - notifications related to warnings triggered by compliance settings
error - notifications related to errors
*/
function getMachineName (machineId) {
function getMachineName(machineId) {
const sql = 'SELECT * FROM devices WHERE device_id=$1'
return db.oneOrNone(sql, [machineId])
.then(it => it.name).catch(logger.error)
return db
.oneOrNone(sql, [machineId])
.then(it => it.name)
.catch(logger.error)
}
const addNotification = (type, message, detail) => {
const sql = `INSERT INTO notifications (id, type, message, detail) VALUES ($1, $2, $3, $4)`
return db.oneOrNone(sql, [uuidv4(), type, message, detail]).catch(logger.error)
return db
.oneOrNone(sql, [uuidv4(), type, message, detail])
.catch(logger.error)
}
const getAllValidNotifications = (type) => {
const getAllValidNotifications = type => {
const sql = `SELECT * FROM notifications WHERE type = $1 AND valid = 't'`
return db.any(sql, [type]).catch(logger.error)
}
@ -37,7 +41,7 @@ const invalidateNotification = (detail, type) => {
return db.none(sql, [type, detail]).catch(logger.error)
}
const batchInvalidate = (ids) => {
const batchInvalidate = ids => {
const formattedIds = _.map(pgp.as.text, ids).join(',')
const sql = `UPDATE notifications SET valid = 'f', read = 't' WHERE id IN ($1^)`
return db.none(sql, [formattedIds]).catch(logger.error)
@ -79,7 +83,10 @@ const hasUnreadNotifications = () => {
(SELECT * FROM notifications
WHERE NOT read AND ${WITHIN_PAST_WEEK})
`
return db.oneOrNone(sql).then(res => res.exists).catch(logger.error)
return db
.oneOrNone(sql)
.then(res => res.exists)
.catch(logger.error)
}
const getAlerts = () => {
@ -105,5 +112,5 @@ module.exports = {
markAllAsRead,
hasUnreadNotifications,
getAlerts,
getMachineName
getMachineName,
}