Save name of trigger in problem

This commit is contained in:
Magnus Åhall 2024-07-04 15:59:29 +02:00
parent 09241e73a5
commit 4d7f0d557e
2 changed files with 7 additions and 6 deletions

View File

@ -39,13 +39,13 @@ func ProblemsRetrieve(showCurrent bool, from, to time.Time) (problems []Problem,
p.acknowledged,
p.datapoints,
t.id AS trigger_id,
t.name AS trigger_name,
p.trigger_name AS trigger_name,
a.name AS area_name,
s.name AS section_name
FROM problem p
INNER JOIN "trigger" t ON p.trigger_id = t.id
INNER JOIN section s ON t.section_id = s.id
INNER JOIN area a ON s.area_id = a.id
LEFT JOIN "trigger" t ON p.trigger_id = t.id
LEFT JOIN section s ON t.section_id = s.id
LEFT JOIN area a ON s.area_id = a.id
WHERE
CASE
WHEN NOT $1 THEN p.end IS NULL
@ -125,8 +125,9 @@ func ProblemStart(trigger Trigger) (problemID int, err error) { // {{{
if openProblems == 0 {
datapointValuesJson, _ := json.Marshal(trigger.DatapointValues)
row = service.Db.Conn.QueryRow(
`INSERT INTO problem(trigger_id, datapoints, trigger_expression) VALUES($1, $2, $3) RETURNING id`,
`INSERT INTO problem(trigger_id, trigger_name, datapoints, trigger_expression) VALUES($1, $2, $3, $4) RETURNING id`,
trigger.ID,
trigger.Name,
datapointValuesJson,
trigger.Expression,
)

View File

@ -26,7 +26,7 @@
<div class="display-list hidden">
<div id="problems-list">
<div style="grid-column: 1/-1;"><h2>Current</h2></div>
<div style="grid-column: 1/-1;"><h2>Unacknowledged</h2></div>
<div class="header">Trigger</div>
<div class="header">Area</div>