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
24461683
Commit
24461683
authored
Jun 02, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort tags in search results, Closes #2091
parent
ff3843bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
2 deletions
+58
-2
pkg/search/handlers.go
+9
-2
pkg/search/handlers_test.go
+49
-0
No files found.
pkg/search/handlers.go
View file @
24461683
...
...
@@ -55,12 +55,19 @@ func searchHandler(query *Query) error {
hits
=
append
(
hits
,
jsonHits
...
)
}
sort
.
Sort
(
hits
)
// add isStarred info
if
err
:=
setIsStarredFlagOnSearchResults
(
query
.
UserId
,
hits
);
err
!=
nil
{
return
err
}
// sort main result array
sort
.
Sort
(
hits
)
// sort tags
for
_
,
hit
:=
range
hits
{
sort
.
Strings
(
hit
.
Tags
)
}
query
.
Result
=
hits
return
nil
}
...
...
pkg/search/handlers_test.go
0 → 100644
View file @
24461683
package
search
import
(
"testing"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
.
"github.com/smartystreets/goconvey/convey"
)
func
TestSearch
(
t
*
testing
.
T
)
{
Convey
(
"Given search query"
,
t
,
func
()
{
jsonDashIndex
=
NewJsonDashIndex
(
"../../public/dashboards/"
)
query
:=
Query
{}
bus
.
AddHandler
(
"test"
,
func
(
query
*
FindPersistedDashboardsQuery
)
error
{
query
.
Result
=
HitList
{
&
Hit
{
Id
:
16
,
Title
:
"CCAA"
,
Tags
:
[]
string
{
"BB"
,
"AA"
}},
&
Hit
{
Id
:
10
,
Title
:
"AABB"
,
Tags
:
[]
string
{
"CC"
,
"AA"
}},
&
Hit
{
Id
:
15
,
Title
:
"BBAA"
,
Tags
:
[]
string
{
"EE"
,
"AA"
,
"BB"
}},
}
return
nil
})
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
.
GetUserStarsQuery
)
error
{
query
.
Result
=
map
[
int64
]
bool
{
10
:
true
,
12
:
true
}
return
nil
})
Convey
(
"That is empty"
,
func
()
{
err
:=
searchHandler
(
&
query
)
So
(
err
,
ShouldBeNil
)
Convey
(
"should return sorted results"
,
func
()
{
So
(
query
.
Result
[
0
]
.
Title
,
ShouldEqual
,
"AABB"
)
So
(
query
.
Result
[
1
]
.
Title
,
ShouldEqual
,
"BBAA"
)
So
(
query
.
Result
[
2
]
.
Title
,
ShouldEqual
,
"CCAA"
)
})
Convey
(
"should return sorted tags"
,
func
()
{
So
(
query
.
Result
[
1
]
.
Tags
[
0
],
ShouldEqual
,
"AA"
)
So
(
query
.
Result
[
1
]
.
Tags
[
1
],
ShouldEqual
,
"BB"
)
So
(
query
.
Result
[
1
]
.
Tags
[
2
],
ShouldEqual
,
"EE"
)
})
})
})
}
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