mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
[search] fix offset param in finddashboards (#100302)
* fix offset param in finddashboards * separate offset from page in k8s search endponit
This commit is contained in:
parent
bf27e6d3ed
commit
7e11e604c7
@ -221,11 +221,14 @@ func (s *SearchHandler) DoSearch(w http.ResponseWriter, r *http.Request) {
|
|||||||
// get limit and offset from query params
|
// get limit and offset from query params
|
||||||
limit := 50
|
limit := 50
|
||||||
offset := 0
|
offset := 0
|
||||||
|
page := 1
|
||||||
if queryParams.Has("limit") {
|
if queryParams.Has("limit") {
|
||||||
limit, _ = strconv.Atoi(queryParams.Get("limit"))
|
limit, _ = strconv.Atoi(queryParams.Get("limit"))
|
||||||
}
|
}
|
||||||
if queryParams.Has("offset") {
|
if queryParams.Has("offset") {
|
||||||
offset, _ = strconv.Atoi(queryParams.Get("offset"))
|
offset, _ = strconv.Atoi(queryParams.Get("offset"))
|
||||||
|
} else if queryParams.Has("page") {
|
||||||
|
page, _ = strconv.Atoi(queryParams.Get("page"))
|
||||||
}
|
}
|
||||||
|
|
||||||
searchRequest := &resource.ResourceSearchRequest{
|
searchRequest := &resource.ResourceSearchRequest{
|
||||||
@ -233,7 +236,7 @@ func (s *SearchHandler) DoSearch(w http.ResponseWriter, r *http.Request) {
|
|||||||
Query: queryParams.Get("query"),
|
Query: queryParams.Get("query"),
|
||||||
Limit: int64(limit),
|
Limit: int64(limit),
|
||||||
Offset: int64(offset),
|
Offset: int64(offset),
|
||||||
Page: int64(offset), // on modes 0-2 (legacy) we use "Page" instead of "Offset"
|
Page: int64(page), // for modes 0-2 (legacy)
|
||||||
Explain: queryParams.Has("explain") && queryParams.Get("explain") != "false",
|
Explain: queryParams.Has("explain") && queryParams.Get("explain") != "false",
|
||||||
}
|
}
|
||||||
fields := []string{"title", "folder", "tags"}
|
fields := []string{"title", "folder", "tags"}
|
||||||
|
@ -1755,7 +1755,7 @@ func (dr *DashboardServiceImpl) searchDashboardsThroughK8sRaw(ctx context.Contex
|
|||||||
|
|
||||||
request.Limit = query.Limit
|
request.Limit = query.Limit
|
||||||
request.Page = query.Page
|
request.Page = query.Page
|
||||||
request.Offset = query.Page - 1 // bleve's offset is 0 indexed
|
request.Offset = (query.Page - 1) * query.Limit // only relevant when running in modes 3+
|
||||||
|
|
||||||
namespace := dr.k8sclient.GetNamespace(query.OrgId)
|
namespace := dr.k8sclient.GetNamespace(query.OrgId)
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
Reference in New Issue
Block a user