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
4ea5d800
Commit
4ea5d800
authored
Jan 20, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various fixes to data access
parent
0a695ba1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
8 deletions
+27
-8
grafana
+1
-1
pkg/api/search.go
+1
-1
pkg/api/user.go
+1
-1
pkg/models/account.go
+1
-1
pkg/services/sqlstore/account_test.go
+10
-1
pkg/services/sqlstore/account_users.go
+2
-1
pkg/services/sqlstore/dashboard.go
+10
-1
pkg/services/sqlstore/dashboard_test.go
+1
-1
No files found.
grafana
@
d9a33680
Subproject commit
590c3b4b50195cacf02fbd0456d55ef69db16b79
Subproject commit
d9a33680a686ac6bc1239797278ad03b3c784d1c
pkg/api/search.go
View file @
4ea5d800
...
...
@@ -17,7 +17,7 @@ func Search(c *middleware.Context) {
}
if
strings
.
HasPrefix
(
queryText
,
"tags!:"
)
{
query
:=
m
.
GetDashboardTagsQuery
{}
query
:=
m
.
GetDashboardTagsQuery
{
AccountId
:
c
.
AccountId
}
err
:=
bus
.
Dispatch
(
&
query
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to get tags from database"
,
err
)
...
...
pkg/api/user.go
View file @
4ea5d800
...
...
@@ -67,7 +67,7 @@ func validateUsingAccount(userId int64, accountId int64) bool {
func
SetUsingAccount
(
c
*
middleware
.
Context
)
{
usingAccountId
:=
c
.
ParamsInt64
(
":id"
)
if
!
validateUsingAccount
(
c
.
Account
Id
,
usingAccountId
)
{
if
!
validateUsingAccount
(
c
.
User
Id
,
usingAccountId
)
{
c
.
JsonApiErr
(
401
,
"Not a valid account"
,
nil
)
return
}
...
...
pkg/models/account.go
View file @
4ea5d800
...
...
@@ -43,7 +43,7 @@ type GetAccountByIdQuery struct {
type
UserAccountDTO
struct
{
AccountId
int64
`json:"accountId"`
Name
string
`json:"
email
"`
Name
string
`json:"
name
"`
Role
RoleType
`json:"role"`
IsUsing
bool
`json:"isUsing"`
}
pkg/services/sqlstore/account_test.go
View file @
4ea5d800
...
...
@@ -59,8 +59,8 @@ func TestAccountDataAccess(t *testing.T) {
err
:=
GetSignedInUser
(
&
query
)
So
(
err
,
ShouldBeNil
)
So
(
query
.
Result
.
AccountId
,
ShouldEqual
,
ac2
.
AccountId
)
So
(
query
.
Result
.
Email
,
ShouldEqual
,
"ac2@test.com"
)
So
(
query
.
Result
.
AccountId
,
ShouldEqual
,
ac2
.
AccountId
)
So
(
query
.
Result
.
Name
,
ShouldEqual
,
"ac2 name"
)
So
(
query
.
Result
.
Login
,
ShouldEqual
,
"ac2"
)
So
(
query
.
Result
.
AccountRole
,
ShouldEqual
,
"Admin"
)
...
...
@@ -76,6 +76,15 @@ func TestAccountDataAccess(t *testing.T) {
So
(
len
(
query
.
Result
),
ShouldEqual
,
2
)
})
Convey
(
"Can get account users"
,
func
()
{
query
:=
m
.
GetAccountUsersQuery
{
AccountId
:
ac1
.
AccountId
}
err
:=
GetAccountUsers
(
&
query
)
So
(
err
,
ShouldBeNil
)
So
(
len
(
query
.
Result
),
ShouldEqual
,
2
)
So
(
query
.
Result
[
0
]
.
Role
,
ShouldEqual
,
"Admin"
)
})
Convey
(
"Can set using account"
,
func
()
{
cmd
:=
m
.
SetUsingAccountCommand
{
UserId
:
ac2
.
Id
,
AccountId
:
ac1
.
Id
}
err
:=
SetUsingAccount
(
&
cmd
)
...
...
pkg/services/sqlstore/account_users.go
View file @
4ea5d800
...
...
@@ -36,7 +36,8 @@ func GetAccountUsers(query *m.GetAccountUsersQuery) error {
sess
:=
x
.
Table
(
"account_user"
)
sess
.
Join
(
"INNER"
,
"user"
,
"account_user.user_id=user.id"
)
sess
.
Where
(
"account_user.account_id=?"
,
query
.
AccountId
)
sess
.
Cols
(
"account_user.account_id"
,
"account_user.user_id"
,
"user.email"
,
"user.login"
)
sess
.
Cols
(
"account_user.account_id"
,
"account_user.user_id"
,
"user.email"
,
"user.login"
,
"account_user.role"
)
sess
.
Asc
(
"user.email"
,
"user.login"
)
err
:=
sess
.
Find
(
&
query
.
Result
)
return
err
...
...
pkg/services/sqlstore/dashboard.go
View file @
4ea5d800
...
...
@@ -120,7 +120,16 @@ func SearchDashboards(query *m.SearchDashboardsQuery) error {
}
func
GetDashboardTags
(
query
*
m
.
GetDashboardTagsQuery
)
error
{
sess
:=
x
.
Sql
(
"select count(*) as count, term from dashboard_tag group by term"
)
sql
:=
`SELECT
COUNT(*) as count,
term
FROM dashboard
INNER JOIN dashboard_tag on dashboard_tag.dashboard_id = dashboard.id
WHERE dashboard.account_id=?
GROUP BY term`
query
.
Result
=
make
([]
*
m
.
DashboardTagCloudItem
,
0
)
sess
:=
x
.
Sql
(
sql
,
query
.
AccountId
)
err
:=
sess
.
Find
(
&
query
.
Result
)
return
err
}
...
...
pkg/services/sqlstore/dashboard_test.go
View file @
4ea5d800
...
...
@@ -90,7 +90,7 @@ func TestDashboardDataAccess(t *testing.T) {
})
Convey
(
"Should be able to get dashboard tags"
,
func
()
{
query
:=
m
.
GetDashboardTagsQuery
{}
query
:=
m
.
GetDashboardTagsQuery
{
AccountId
:
1
}
err
:=
GetDashboardTags
(
&
query
)
So
(
err
,
ShouldBeNil
)
...
...
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