diff --git a/pkg/api/search.go b/pkg/api/search.go index b1ae9bcc241..b848d2a097c 100644 --- a/pkg/api/search.go +++ b/pkg/api/search.go @@ -33,6 +33,11 @@ func setIsStarredFlagOnSearchResults(c *middleware.Context, hits []*m.DashboardS func Search(c *middleware.Context) { queryText := c.Query("q") starred := c.Query("starred") + limit := c.QueryInt("limit") + + if limit == 0 { + limit = 200 + } result := m.SearchResult{ Dashboards: []*m.DashboardSearchHit{}, @@ -58,6 +63,7 @@ func Search(c *middleware.Context) { Title: matches[3], Tag: matches[2], UserId: c.UserId, + Limit: limit, IsStarred: starred == "1", AccountId: c.AccountId, } diff --git a/pkg/models/search.go b/pkg/models/search.go index e23b5dbd5aa..4f5b24ff084 100644 --- a/pkg/models/search.go +++ b/pkg/models/search.go @@ -25,6 +25,7 @@ type SearchDashboardsQuery struct { Tag string AccountId int64 UserId int64 + Limit int IsStarred bool Result []*DashboardSearchHit diff --git a/pkg/services/sqlstore/dashboard.go b/pkg/services/sqlstore/dashboard.go index f9668731ab5..b3c0495a42f 100644 --- a/pkg/services/sqlstore/dashboard.go +++ b/pkg/services/sqlstore/dashboard.go @@ -2,6 +2,7 @@ package sqlstore import ( "bytes" + "fmt" "github.com/go-xorm/xorm" "github.com/grafana/grafana/pkg/bus" @@ -116,6 +117,8 @@ func SearchDashboards(query *m.SearchDashboardsQuery) error { params = append(params, query.Tag) } + sql.WriteString(fmt.Sprintf(" LIMIT %d", query.Limit)) + var res []DashboardSearchProjection err := x.Sql(sql.String(), params...).Find(&res) if err != nil { diff --git a/src/app/features/account/partials/import.html b/src/app/features/account/partials/import.html index 28c695ca068..f94b5e7c7e8 100644 --- a/src/app/features/account/partials/import.html +++ b/src/app/features/account/partials/import.html @@ -19,18 +19,18 @@