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
5a3ba68a
Commit
5a3ba68a
authored
Mar 16, 2018
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
database: fixes after xorm update
parent
1c20126f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
5 deletions
+18
-5
pkg/services/sqlstore/alert.go
+1
-1
pkg/services/sqlstore/dashboard_folder_test.go
+1
-0
pkg/services/sqlstore/org_test.go
+3
-0
pkg/services/sqlstore/quota.go
+5
-0
pkg/services/sqlstore/quota_test.go
+2
-2
pkg/services/sqlstore/sqlstore.go
+6
-2
No files found.
pkg/services/sqlstore/alert.go
View file @
5a3ba68a
...
...
@@ -255,7 +255,7 @@ func SetAlertState(cmd *m.SetAlertStateCommand) error {
}
alert
.
State
=
cmd
.
State
alert
.
StateChanges
+=
1
alert
.
StateChanges
++
alert
.
NewStateDate
=
timeNow
()
alert
.
EvalData
=
cmd
.
EvalData
...
...
pkg/services/sqlstore/dashboard_folder_test.go
View file @
5a3ba68a
...
...
@@ -46,6 +46,7 @@ func TestDashboardFolderDataAccess(t *testing.T) {
OrgId
:
1
,
DashboardIds
:
[]
int64
{
folder
.
Id
,
dashInRoot
.
Id
},
}
err
:=
SearchDashboards
(
query
)
So
(
err
,
ShouldBeNil
)
So
(
len
(
query
.
Result
),
ShouldEqual
,
1
)
So
(
query
.
Result
[
0
]
.
Id
,
ShouldEqual
,
dashInRoot
.
Id
)
...
...
pkg/services/sqlstore/org_test.go
View file @
5a3ba68a
...
...
@@ -2,6 +2,7 @@ package sqlstore
import
(
"testing"
"time"
.
"github.com/smartystreets/goconvey/convey"
...
...
@@ -241,6 +242,8 @@ func TestAccountDataAccess(t *testing.T) {
func
testHelperUpdateDashboardAcl
(
dashboardId
int64
,
items
...
m
.
DashboardAcl
)
error
{
cmd
:=
m
.
UpdateDashboardAclCommand
{
DashboardId
:
dashboardId
}
for
_
,
item
:=
range
items
{
item
.
Created
=
time
.
Now
()
item
.
Updated
=
time
.
Now
()
cmd
.
Items
=
append
(
cmd
.
Items
,
&
item
)
}
return
UpdateDashboardAcl
(
&
cmd
)
...
...
pkg/services/sqlstore/quota.go
View file @
5a3ba68a
...
...
@@ -2,6 +2,7 @@ package sqlstore
import
(
"fmt"
"time"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
...
...
@@ -100,6 +101,7 @@ func UpdateOrgQuota(cmd *m.UpdateOrgQuotaCmd) error {
quota
:=
m
.
Quota
{
Target
:
cmd
.
Target
,
OrgId
:
cmd
.
OrgId
,
Updated
:
time
.
Now
(),
}
has
,
err
:=
sess
.
Get
(
&
quota
)
if
err
!=
nil
{
...
...
@@ -107,6 +109,7 @@ func UpdateOrgQuota(cmd *m.UpdateOrgQuotaCmd) error {
}
quota
.
Limit
=
cmd
.
Limit
if
has
==
false
{
quota
.
Created
=
time
.
Now
()
//No quota in the DB for this target, so create a new one.
if
_
,
err
:=
sess
.
Insert
(
&
quota
);
err
!=
nil
{
return
err
...
...
@@ -200,6 +203,7 @@ func UpdateUserQuota(cmd *m.UpdateUserQuotaCmd) error {
quota
:=
m
.
Quota
{
Target
:
cmd
.
Target
,
UserId
:
cmd
.
UserId
,
Updated
:
time
.
Now
(),
}
has
,
err
:=
sess
.
Get
(
&
quota
)
if
err
!=
nil
{
...
...
@@ -207,6 +211,7 @@ func UpdateUserQuota(cmd *m.UpdateUserQuotaCmd) error {
}
quota
.
Limit
=
cmd
.
Limit
if
has
==
false
{
quota
.
Created
=
time
.
Now
()
//No quota in the DB for this target, so create a new one.
if
_
,
err
:=
sess
.
Insert
(
&
quota
);
err
!=
nil
{
return
err
...
...
pkg/services/sqlstore/quota_test.go
View file @
5a3ba68a
...
...
@@ -104,12 +104,12 @@ func TestQuotaCommandsAndQueries(t *testing.T) {
})
})
Convey
(
"Given saved user quota for org"
,
func
()
{
userQ
ou
taCmd
:=
m
.
UpdateUserQuotaCmd
{
userQ
uo
taCmd
:=
m
.
UpdateUserQuotaCmd
{
UserId
:
userId
,
Target
:
"org_user"
,
Limit
:
10
,
}
err
:=
UpdateUserQuota
(
&
userQ
ou
taCmd
)
err
:=
UpdateUserQuota
(
&
userQ
uo
taCmd
)
So
(
err
,
ShouldBeNil
)
Convey
(
"Should be able to get saved quota by user id and target"
,
func
()
{
...
...
pkg/services/sqlstore/sqlstore.go
View file @
5a3ba68a
...
...
@@ -8,6 +8,7 @@ import (
"path/filepath"
"strings"
"testing"
"time"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/log"
...
...
@@ -225,8 +226,8 @@ var (
func
InitTestDB
(
t
*
testing
.
T
)
*
xorm
.
Engine
{
selectedDb
:=
dbSqlite
//selectedDb := dbMySql
//selectedDb := dbPostgres
//
selectedDb := dbMySql
//
selectedDb := dbPostgres
var
x
*
xorm
.
Engine
var
err
error
...
...
@@ -245,6 +246,9 @@ func InitTestDB(t *testing.T) *xorm.Engine {
x
,
err
=
xorm
.
NewEngine
(
sqlutil
.
TestDB_Sqlite3
.
DriverName
,
sqlutil
.
TestDB_Sqlite3
.
ConnStr
)
}
x
.
DatabaseTZ
=
time
.
UTC
x
.
TZLocation
=
time
.
UTC
// x.ShowSQL()
if
err
!=
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