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
d89c1260
Commit
d89c1260
authored
Jun 17, 2017
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: refactor dash search and remove extra query
parent
5cf40cbd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
18 deletions
+8
-18
pkg/services/sqlstore/dashboard.go
+8
-18
No files found.
pkg/services/sqlstore/dashboard.go
View file @
d89c1260
...
@@ -154,6 +154,8 @@ type DashboardSearchProjection struct {
...
@@ -154,6 +154,8 @@ type DashboardSearchProjection struct {
Term
string
Term
string
IsFolder
bool
IsFolder
bool
ParentId
int64
ParentId
int64
FolderSlug
string
FolderTitle
string
}
}
func
findDashboards
(
query
*
search
.
FindPersistedDashboardsQuery
)
([]
DashboardSearchProjection
,
error
)
{
func
findDashboards
(
query
*
search
.
FindPersistedDashboardsQuery
)
([]
DashboardSearchProjection
,
error
)
{
...
@@ -167,9 +169,10 @@ func findDashboards(query *search.FindPersistedDashboardsQuery) ([]DashboardSear
...
@@ -167,9 +169,10 @@ func findDashboards(query *search.FindPersistedDashboardsQuery) ([]DashboardSear
dashboard_tag.term,
dashboard_tag.term,
dashboard.is_folder,
dashboard.is_folder,
dashboard.parent_id,
dashboard.parent_id,
pd.title as folder_title
f.slug as folder_slug,
f.title as folder_title
FROM dashboard
FROM dashboard
LEFT OUTER JOIN dashboard
pd on pd
.id = dashboard.parent_id
LEFT OUTER JOIN dashboard
f on f
.id = dashboard.parent_id
LEFT OUTER JOIN dashboard_tag on dashboard_tag.dashboard_id = dashboard.id`
)
LEFT OUTER JOIN dashboard_tag on dashboard_tag.dashboard_id = dashboard.id`
)
if
query
.
IsStarred
{
if
query
.
IsStarred
{
...
@@ -268,26 +271,13 @@ func SearchDashboards(query *search.FindPersistedDashboardsQuery) error {
...
@@ -268,26 +271,13 @@ func SearchDashboards(query *search.FindPersistedDashboardsQuery) error {
// appends parent folders for any hits to the search result
// appends parent folders for any hits to the search result
func
appendDashboardFolders
(
res
[]
DashboardSearchProjection
)
([]
DashboardSearchProjection
,
error
)
{
func
appendDashboardFolders
(
res
[]
DashboardSearchProjection
)
([]
DashboardSearchProjection
,
error
)
{
var
dashboardFolderIds
[]
int64
for
_
,
item
:=
range
res
{
for
_
,
item
:=
range
res
{
if
item
.
ParentId
>
0
{
if
item
.
ParentId
>
0
{
dashboardFolderIds
=
append
(
dashboardFolderIds
,
item
.
ParentId
)
}
}
if
len
(
dashboardFolderIds
)
>
0
{
folderQuery
:=
&
m
.
GetDashboardsQuery
{
DashboardIds
:
dashboardFolderIds
}
err
:=
GetDashboards
(
folderQuery
)
if
err
!=
nil
{
return
nil
,
err
}
for
_
,
folder
:=
range
folderQuery
.
Result
{
res
=
append
(
res
,
DashboardSearchProjection
{
res
=
append
(
res
,
DashboardSearchProjection
{
Id
:
folder
.
Id
,
Id
:
item
.
Parent
Id
,
IsFolder
:
true
,
IsFolder
:
true
,
Slug
:
folder
.
Slug
,
Slug
:
item
.
Folder
Slug
,
Title
:
folder
.
Title
,
Title
:
item
.
Folder
Title
,
})
})
}
}
}
}
...
...
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