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
6c2c3c7e
Commit
6c2c3c7e
authored
Dec 19, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "fix(alerting): pause dto can only pause one"
This reverts commit
b2c5a6a0
.
parent
b2c5a6a0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
11 deletions
+27
-11
pkg/api/alerting.go
+5
-4
pkg/models/alert.go
+4
-3
pkg/services/sqlstore/alert.go
+18
-4
No files found.
pkg/api/alerting.go
View file @
6c2c3c7e
...
...
@@ -259,10 +259,11 @@ func NotificationTest(c *middleware.Context, dto dtos.NotificationTestCommand) R
//POST /api/alerts/:alertId/pause
func
PauseAlert
(
c
*
middleware
.
Context
,
dto
dtos
.
PauseAlertCommand
)
Response
{
alertId
:=
c
.
ParamsInt64
(
"alertId"
)
cmd
:=
models
.
PauseAlertCommand
{
OrgId
:
c
.
OrgId
,
AlertId
:
c
.
ParamsInt64
(
"alertId"
)
,
Paused
:
dto
.
Paused
,
OrgId
:
c
.
OrgId
,
AlertId
s
:
[]
int64
{
alertId
}
,
Paused
:
dto
.
Paused
,
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
...
...
@@ -277,7 +278,7 @@ func PauseAlert(c *middleware.Context, dto dtos.PauseAlertCommand) Response {
}
result
:=
map
[
string
]
interface
{}{
"alertId"
:
c
.
ParamsInt64
(
"alertId"
)
,
"alertId"
:
alertId
,
"state"
:
response
,
"message"
:
"alert "
+
pausedState
,
}
...
...
pkg/models/alert.go
View file @
6c2c3c7e
...
...
@@ -138,9 +138,10 @@ type SaveAlertsCommand struct {
}
type
PauseAlertCommand
struct
{
OrgId
int64
AlertId
int64
Paused
bool
OrgId
int64
AlertIds
[]
int64
ResultCount
int64
Paused
bool
}
type
PauseAllAlertCommand
struct
{
...
...
pkg/services/sqlstore/alert.go
View file @
6c2c3c7e
...
...
@@ -3,6 +3,7 @@ package sqlstore
import
(
"bytes"
"fmt"
"strings"
"time"
"github.com/go-xorm/xorm"
...
...
@@ -251,18 +252,31 @@ func SetAlertState(cmd *m.SetAlertStateCommand) error {
func
PauseAlert
(
cmd
*
m
.
PauseAlertCommand
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
if
len
(
cmd
.
AlertIds
)
==
0
{
return
fmt
.
Errorf
(
"command contains no alertids"
)
}
var
buffer
bytes
.
Buffer
params
:=
make
([]
interface
{},
0
)
sql
:=
`UPDATE alert SET state = ? WHERE id = ?`
buffer
.
WriteString
(
`UPDATE alert SET state = ?`
)
if
cmd
.
Paused
{
params
=
append
(
params
,
string
(
m
.
AlertStatePaused
))
}
else
{
params
=
append
(
params
,
string
(
m
.
AlertStatePending
))
}
params
=
append
(
params
,
cmd
.
AlertId
)
_
,
err
:=
sess
.
Exec
(
sql
,
params
...
)
return
err
buffer
.
WriteString
(
` WHERE id IN (?`
+
strings
.
Repeat
(
",?"
,
len
(
cmd
.
AlertIds
)
-
1
)
+
`)`
)
for
_
,
v
:=
range
cmd
.
AlertIds
{
params
=
append
(
params
,
v
)
}
res
,
err
:=
sess
.
Exec
(
buffer
.
String
(),
params
...
)
if
err
!=
nil
{
return
err
}
cmd
.
ResultCount
,
_
=
res
.
RowsAffected
()
return
nil
})
}
...
...
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