Add Pagination Options for List Requests #205
Merged
lunny
merged 36 commits from spawn2kill/go-sdk:pagination
into master
2 years ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'spawn2kill/go-sdk:pagination'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Same as #203
Please resolve the conflicts
@lunny only worth it after https://github.com/go-gitea/gitea/pull/9452 got merged ...
but it looks like nobody has time to review :/
@spawn2kill can you adjust this PR ? (now as your PR is merged upstream)
and fix conflict ;)
I will as soon as I get some free time :)
dont stress yourself ... since this will be a breaking change. And v0.11.0 is released first
By the way you should add a version check like this one:
7892df812a
And once again, an huge PR 😂
this need a litle b8t more work
why differ from
models/list_options.go
struct ?fixed
gitea/issue_milestone.go
-> #244ListrecourceOption
why remove the copyright header?
fixed
PerPage int
}
func (o ListOptions) getURLQueryEncoded() string {
useles function you always can use
getURLQuery().Encode()
instead}
}
func (o ListOptions) getPerPage() int {
i would ceep it simple and would remove
getPerPage()
instead use:
it makes it clear what the code does
}
// ListOrgHooksOptions options for listing organization's hooks
type ListOrgHooksOptions struct {
why not use ListHooksOptions for ListOrgHooks() and ListRepoHooks() ?
fixed
link.RawQuery = options.QueryEncode()
return issues, c.getParsedResponse("GET", link.String(), jsonHeader, nil, &issues)
}
dont delete
if len(opt.State) > 0 { ...
it was actually duplicated
o your right ... in this case it sure ok :)
I already have this fix in #243 :D
this could cause you or me a mergeconflict :)
options.setDefaults()
comments := make([]*Comment, 0, options.PageSize)
if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil {
return comments, err
why make this function unusable for gitea instances below 1.12.0 ?!?
fixed
}
func (o ListOptions) getURLQuery() url.Values {
o.setDefaults()
i would not implicit setDefaults as you have it explicit on each function anyway (give more indifidual control to each api call function)
fixed
o.Page = 1
}
if o.PageSize < 0 || o.PageSize > 50 {
can you add a varialbe on the beginging of
gitea/list_options.go
witch contain this vaule (50)?fixed
}
// ListMyOrgsOptions options for listing current user's organizations
type ListMyOrgsOptions struct {
can you let
ListMyOrgs()
andListUserOrgs()
useListOrgsOptions
?fixed
}
// ListOrgTeamsOptions options for listing organization's teams
type ListOrgTeamsOptions struct {
same here -> ListTeamsOptions for ListOrgTeams() & ListMyTeams()
fixed
// ListPullRequestsOptions options for listing pull requests
type ListPullRequestsOptions struct {
Page int `json:"page"`
ListOptions `json:"-"`
just use
ListOptions
fixed
}
// ListMyReposOptions options for listing current's user repositories
type ListMyReposOptions struct {
ListReposOptions ... for ListMyRepos() ListUserRepos() ListOrgReposOptions()
fixed
func (c *Client) ListMyFollowing(page int) ([]*User, error) {
users := make([]*User, 0, 10)
return users, c.getParsedResponse("GET", fmt.Sprintf("/user/following?page=%d", page), nil, nil, &users)
func (c *Client) ListMyFollowing(options ListMyFollowingOptions) ([]*User, error) {
use ListFollowingOptions for ListMyFollowing() too
fixed
import "fmt"
// ListMyFollowersOptions options for listing current's user's followers
type ListMyFollowersOptions struct {
use ListFollowersOptions for ListMyFollowers() too
fixed
}
// ListMyGPGKeys list all the GPG keys of current user
func (c *Client) ListMyGPGKeys() ([]*GPGKey, error) {
use ListMyGPGKeysOption for ListMyGPGKeys() too
fixed
}
// ListGPGKeys options for listing a user's GPGKeys
type ListGPGKeys struct {
fixed
func (c *Client) ListMyPublicKeys() ([]*PublicKey, error) {
keys := make([]*PublicKey, 0, 10)
return keys, c.getParsedResponse("GET", "/user/keys", nil, nil, &keys)
func (c *Client) ListMyPublicKeys(options ListMyPublicKeysOptions) ([]*PublicKey, error) {
use ListPublicKeysOptions for ListMyPublicKeys() too
fixed
need still some work
}
// ListRepoLabelsOptions options for listing repository's labels
type ListRepoLabelsOptions struct {
ListLabelsOptions for ListRepoLabels() and GetIssueLabels()
// ListRepoTopics list all repository's topics
func (c *Client) ListRepoTopics(user, repo string, opt ListRepoTopics) (*TopicsList, error) {
var list TopicsList
opt.setDefaults()
still some nits
🎉
@spawn2kill #254 is merged, so now you can also add pagination to it in this PR
pleace resolve conflict
gitea/issue_comment.go
gitea/user_app.go
// ListRepoIssueComments list comments for a given repo.
func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) {
comments := make([]*Comment, 0, 10)
can you use ListIssueCommentsOptions for ListRepoIssueComments too?
found something
can you pleace resolve the conflichts ... yes they are back again :O
test-instance:
rm -r ${WORK_DIR}/test 2> /dev/null; \
mkdir -p ${WORK_DIR}/test/conf/ ${WORK_DIR}/test/data/
wget "https://dl.gitea.io/gitea/master/gitea-master-darwin-10.6-amd64" -O ${WORK_DIR}/test/gitea-master; \
better use
git add -p
?func (c *Client) ListMyRepos() ([]*Repository, error) {
repos := make([]*Repository, 0, 10)
return repos, c.getParsedResponse("GET", "/user/repos", nil, nil, &repos)
func (c *Client) ListMyRepos(opt *ListReposOptions) ([]*Repository, error) {
opt *ListReposOptions
->opt ListReposOptions
jsonHeader, bytes.NewReader(body), status)
status := new(Status)
return status, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, sha), jsonHeader, bytes.NewReader(body), status)
}
dont breake things if necesar!!
rename
ListStatusesOptions
back toListStatusesOption
}
// ListAccessTokens options for listing a users's access tokens
type ListAccessTokens struct {
rename to ListAccessTokensOptions
lgtm
So this is major breaking change for the SDK almost every signature is changed.
added pagination options for listing requeststo Add Pagination Options for List Requests 2 years agoe7bf8a6842
.