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
6ef941ea
Unverified
Commit
6ef941ea
authored
Nov 02, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix failing tests
parent
940f5108
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
pkg/services/sqlstore/sqlstore.go
+1
-0
pkg/services/sqlstore/user.go
+14
-9
No files found.
pkg/services/sqlstore/sqlstore.go
View file @
6ef941ea
...
...
@@ -326,6 +326,7 @@ func InitTestDB(t *testing.T) *SqlStore {
sqlstore
:=
&
SqlStore
{}
sqlstore
.
skipEnsureAdmin
=
true
sqlstore
.
Bus
=
bus
.
New
()
sqlstore
.
CacheService
=
cache
.
New
(
5
*
time
.
Minute
,
10
*
time
.
Minute
)
dbType
:=
migrator
.
SQLITE
...
...
pkg/services/sqlstore/user.go
View file @
6ef941ea
...
...
@@ -16,7 +16,7 @@ import (
)
func
(
ss
*
SqlStore
)
addUserQueryAndCommandHandlers
()
{
ss
.
Bus
.
AddHandler
(
ss
.
GetSignedInUser
)
ss
.
Bus
.
AddHandler
(
ss
.
GetSignedInUser
WithCache
)
bus
.
AddHandler
(
"sql"
,
GetUserById
)
bus
.
AddHandler
(
"sql"
,
UpdateUser
)
...
...
@@ -345,18 +345,24 @@ func GetUserOrgList(query *m.GetUserOrgListQuery) error {
return
err
}
func
(
ss
*
SqlStore
)
GetSignedInUser
(
query
*
m
.
GetSignedInUserQuery
)
error
{
orgId
:=
"u.org_id"
if
query
.
OrgId
>
0
{
orgId
=
strconv
.
FormatInt
(
query
.
OrgId
,
10
)
}
cacheKey
:=
fmt
.
Sprintf
(
"signed-in-user-%d-%s"
,
query
.
UserId
,
query
.
OrgId
)
func
(
ss
*
SqlStore
)
GetSignedInUserWithCache
(
query
*
m
.
GetSignedInUserQuery
)
error
{
cacheKey
:=
fmt
.
Sprintf
(
"signed-in-user-%d-%d"
,
query
.
UserId
,
query
.
OrgId
)
if
cached
,
found
:=
ss
.
CacheService
.
Get
(
cacheKey
);
found
{
query
.
Result
=
cached
.
(
*
m
.
SignedInUser
)
return
nil
}
err
:=
GetSignedInUser
(
query
)
ss
.
CacheService
.
Set
(
cacheKey
,
query
.
Result
,
time
.
Second
*
5
)
return
err
}
func
GetSignedInUser
(
query
*
m
.
GetSignedInUserQuery
)
error
{
orgId
:=
"u.org_id"
if
query
.
OrgId
>
0
{
orgId
=
strconv
.
FormatInt
(
query
.
OrgId
,
10
)
}
var
rawSql
=
`SELECT
u.id as user_id,
u.is_admin as is_grafana_admin,
...
...
@@ -407,7 +413,6 @@ func (ss *SqlStore) GetSignedInUser(query *m.GetSignedInUserQuery) error {
}
query
.
Result
=
&
user
ss
.
CacheService
.
Set
(
cacheKey
,
&
user
,
time
.
Second
*
5
)
return
err
}
...
...
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