Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
46bab0bb
Commit
46bab0bb
authored
Oct 14, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): remove annotations when deleting alert, closes #6244
parent
c9d7eb0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
pkg/services/sqlstore/alert.go
+17
-17
No files found.
pkg/services/sqlstore/alert.go
View file @
46bab0bb
...
...
@@ -46,13 +46,23 @@ func GetAllAlertQueryHandler(query *m.GetAllAlertsQuery) error {
return
nil
}
func
deleteAlertByIdInternal
(
alertId
int64
,
reason
string
,
sess
*
xorm
.
Session
)
error
{
sqlog
.
Debug
(
"Deleting alert"
,
"id"
,
alertId
,
"reason"
,
reason
)
if
_
,
err
:=
sess
.
Exec
(
"DELETE FROM alert WHERE id = ?"
,
alertId
);
err
!=
nil
{
return
err
}
if
_
,
err
:=
sess
.
Exec
(
"DELETE FROM annotation WHERE alert_id = ?"
,
alertId
);
err
!=
nil
{
return
err
}
return
nil
}
func
DeleteAlertById
(
cmd
*
m
.
DeleteAlertCommand
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
if
_
,
err
:=
sess
.
Exec
(
"DELETE FROM alert WHERE id = ?"
,
cmd
.
AlertId
);
err
!=
nil
{
return
err
}
return
nil
return
deleteAlertByIdInternal
(
cmd
.
AlertId
,
"DeleteAlertCommand"
,
sess
)
})
}
...
...
@@ -110,12 +120,7 @@ func DeleteAlertDefinition(dashboardId int64, sess *xorm.Session) error {
sess
.
Where
(
"dashboard_id = ?"
,
dashboardId
)
.
Find
(
&
alerts
)
for
_
,
alert
:=
range
alerts
{
_
,
err
:=
sess
.
Exec
(
"DELETE FROM alert WHERE id = ? "
,
alert
.
Id
)
if
err
!=
nil
{
return
err
}
sqlog
.
Debug
(
"Alert deleted (due to dashboard deletion)"
,
"name"
,
alert
.
Name
,
"id"
,
alert
.
Id
)
deleteAlertByIdInternal
(
alert
.
Id
,
"Dashboard deleted"
,
sess
)
}
return
nil
...
...
@@ -195,12 +200,7 @@ func deleteMissingAlerts(alerts []*m.Alert, cmd *m.SaveAlertsCommand, sess *xorm
}
if
missing
{
_
,
err
:=
sess
.
Exec
(
"DELETE FROM alert WHERE id = ?"
,
missingAlert
.
Id
)
if
err
!=
nil
{
return
err
}
sqlog
.
Debug
(
"Alert deleted"
,
"name"
,
missingAlert
.
Name
,
"id"
,
missingAlert
.
Id
)
deleteAlertByIdInternal
(
missingAlert
.
Id
,
"Removed from dashboard"
,
sess
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment