Time filtering of notifications

This commit is contained in:
Magnus Åhall 2024-06-29 19:30:26 +02:00
parent b0ffce05f0
commit 17a22caa5d
9 changed files with 291 additions and 10 deletions

View file

@ -40,7 +40,7 @@ func notificationLog(notificationService *notification.Service, problemID int, e
}
}
func notificationsSent() (nss []NotificationSend, err error) {
func notificationsSent(from, to time.Time) (nss []NotificationSend, err error) {
var rows *sqlx.Rows
rows, err = service.Db.Conn.Queryx(
`
@ -57,15 +57,20 @@ func notificationsSent() (nss []NotificationSend, err error) {
ns.error::varchar,
ns.acknowledged
FROM
public.notification_send ns
FROM public.notification_send ns
INNER JOIN notification n ON ns.notification_id = n.id
INNER JOIN problem p ON ns.problem_id = p.id
INNER JOIN "trigger" t ON p.trigger_id = t.id
WHERE
ns.send >= $1 AND
ns.send <= $2
ORDER BY
send DESC
`)
`,
from,
to,
)
if err != nil {
err = werr.Wrap(err)
return