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
132df455
Commit
132df455
authored
Jun 25, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: annnotation api & sql issue
parent
ed1fec8e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
15 deletions
+20
-15
pkg/api/annotations.go
+3
-0
pkg/services/annotations/annotations.go
+6
-5
pkg/services/sqlstore/annotation.go
+10
-9
pkg/services/sqlstore/annotation_test.go
+1
-1
No files found.
pkg/api/annotations.go
View file @
132df455
...
...
@@ -213,6 +213,7 @@ func DeleteAnnotations(c *m.ReqContext, cmd dtos.DeleteAnnotationsCmd) Response
repo
:=
annotations
.
GetRepository
()
err
:=
repo
.
Delete
(
&
annotations
.
DeleteParams
{
OrgId
:
c
.
OrgId
,
Id
:
cmd
.
AnnotationId
,
RegionId
:
cmd
.
RegionId
,
DashboardId
:
cmd
.
DashboardId
,
...
...
@@ -235,6 +236,7 @@ func DeleteAnnotationByID(c *m.ReqContext) Response {
}
err
:=
repo
.
Delete
(
&
annotations
.
DeleteParams
{
OrgId
:
c
.
OrgId
,
Id
:
annotationID
,
})
...
...
@@ -254,6 +256,7 @@ func DeleteAnnotationRegion(c *m.ReqContext) Response {
}
err
:=
repo
.
Delete
(
&
annotations
.
DeleteParams
{
OrgId
:
c
.
OrgId
,
RegionId
:
regionID
,
})
...
...
pkg/services/annotations/annotations.go
View file @
132df455
...
...
@@ -35,11 +35,12 @@ type PostParams struct {
}
type
DeleteParams
struct
{
Id
int64
`json:"id"`
AlertId
int64
`json:"alertId"`
DashboardId
int64
`json:"dashboardId"`
PanelId
int64
`json:"panelId"`
RegionId
int64
`json:"regionId"`
OrgId
int64
Id
int64
AlertId
int64
DashboardId
int64
PanelId
int64
RegionId
int64
}
var
repositoryInstance
Repository
...
...
pkg/services/sqlstore/annotation.go
View file @
132df455
...
...
@@ -238,18 +238,19 @@ func (r *SqlAnnotationRepo) Delete(params *annotations.DeleteParams) error {
queryParams
[]
interface
{}
)
sqlog
.
Info
(
"delete"
,
"orgId"
,
params
.
OrgId
)
if
params
.
RegionId
!=
0
{
annoTagSql
=
"DELETE FROM annotation_tag WHERE annotation_id IN (SELECT id FROM annotation WHERE region_id = ?)"
sql
=
"DELETE FROM annotation WHERE region_id = ?"
queryParams
=
[]
interface
{}{
params
.
RegionId
}
annoTagSql
=
"DELETE FROM annotation_tag WHERE annotation_id IN (SELECT id FROM annotation WHERE region_id = ?
AND org_id = ?
)"
sql
=
"DELETE FROM annotation WHERE region_id = ?
AND org_id = ?
"
queryParams
=
[]
interface
{}{
params
.
RegionId
,
params
.
OrgId
}
}
else
if
params
.
Id
!=
0
{
annoTagSql
=
"DELETE FROM annotation_tag WHERE annotation_id IN (SELECT id FROM annotation WHERE id = ?)"
sql
=
"DELETE FROM annotation WHERE id = ?"
queryParams
=
[]
interface
{}{
params
.
Id
}
annoTagSql
=
"DELETE FROM annotation_tag WHERE annotation_id IN (SELECT id FROM annotation WHERE id = ?
AND org_id = ?
)"
sql
=
"DELETE FROM annotation WHERE id = ?
AND org_id = ?
"
queryParams
=
[]
interface
{}{
params
.
Id
,
params
.
OrgId
}
}
else
{
annoTagSql
=
"DELETE FROM annotation_tag WHERE annotation_id IN (SELECT id FROM annotation WHERE dashboard_id = ? AND panel_id = ?)"
sql
=
"DELETE FROM annotation WHERE dashboard_id = ? AND panel_id = ?"
queryParams
=
[]
interface
{}{
params
.
DashboardId
,
params
.
PanelId
}
annoTagSql
=
"DELETE FROM annotation_tag WHERE annotation_id IN (SELECT id FROM annotation WHERE dashboard_id = ? AND panel_id = ?
AND org_id = ?
)"
sql
=
"DELETE FROM annotation WHERE dashboard_id = ? AND panel_id = ?
AND org_id = ?
"
queryParams
=
[]
interface
{}{
params
.
DashboardId
,
params
.
PanelId
,
params
.
OrgId
}
}
if
_
,
err
:=
sess
.
Exec
(
annoTagSql
,
queryParams
...
);
err
!=
nil
{
...
...
pkg/services/sqlstore/annotation_test.go
View file @
132df455
...
...
@@ -268,7 +268,7 @@ func TestAnnotations(t *testing.T) {
annotationId
:=
items
[
0
]
.
Id
err
=
repo
.
Delete
(
&
annotations
.
DeleteParams
{
Id
:
annotationId
})
err
=
repo
.
Delete
(
&
annotations
.
DeleteParams
{
Id
:
annotationId
,
OrgId
:
1
})
So
(
err
,
ShouldBeNil
)
items
,
err
=
repo
.
Find
(
query
)
...
...
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