MM-18357: Adds pagination to team search. (#12910)
* MM-18357: Adds pagination to team search. * MM-18357: Adds new client method for paginated requests. * MM-18357: Adds feedback about non-supported pagination-permissions combo. * MM-18357: Removes unnecessary conversion. * MM-18357: Removes paginate parameter and uses nil on page and perpage instead.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
955f8c4e8e
Коммит
14bcd1f0a1
@@ -1661,6 +1661,23 @@ func (c *Client4) SearchTeams(search *TeamSearch) ([]*Team, *Response) {
|
||||
return TeamListFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
|
||||
// SearchTeamsPaged returns a page of teams and the total count matching the provided search term.
|
||||
func (c *Client4) SearchTeamsPaged(search *TeamSearch) ([]*Team, int64, *Response) {
|
||||
if search.Page == nil {
|
||||
search.Page = NewInt(0)
|
||||
}
|
||||
if search.PerPage == nil {
|
||||
search.PerPage = NewInt(100)
|
||||
}
|
||||
r, err := c.DoApiPost(c.GetTeamsRoute()+"/search", search.ToJson())
|
||||
if err != nil {
|
||||
return nil, 0, BuildErrorResponse(r, err)
|
||||
}
|
||||
defer closeBody(r)
|
||||
twc := TeamsWithCountFromJson(r.Body)
|
||||
return twc.Teams, twc.TotalCount, BuildResponse(r)
|
||||
}
|
||||
|
||||
// TeamExists returns true or false if the team exist or not.
|
||||
func (c *Client4) TeamExists(name, etag string) (bool, *Response) {
|
||||
r, err := c.DoApiGet(c.GetTeamByNameRoute(name)+"/exists", etag)
|
||||
|
||||
@@ -9,7 +9,13 @@ import (
|
||||
)
|
||||
|
||||
type TeamSearch struct {
|
||||
Term string `json:"term"`
|
||||
Term string `json:"term"`
|
||||
Page *int `json:"page,omitempty"`
|
||||
PerPage *int `json:"per_page,omitempty"`
|
||||
}
|
||||
|
||||
func (t *TeamSearch) IsPaginated() bool {
|
||||
return t.Page != nil && t.PerPage != nil
|
||||
}
|
||||
|
||||
// ToJson convert a TeamSearch to json string
|
||||
|
||||
Ссылка в новой задаче
Block a user