Use issue list API instead of search #78

Merged
lunny merged 2 commits from jolheiser/changelog:issue-search into main 2023-07-20 10:08:50 +00:00
Owner

This PR changes to using the GH issue list API rather than search, as for some reason the search results started missing several PRs...

This PR changes to using the GH issue list API rather than search, as for some reason the search results started missing several PRs...
jolheiser added the
enhancement
label 2023-04-27 04:37:57 +00:00
silverwind approved these changes 2023-04-27 09:30:04 +00:00
jolheiser reviewed 2023-04-27 23:04:56 +00:00
@ -27,0 +31,4 @@
func (gh *GitHub) OwnerRepo() (string, string) {
parts := strings.Split(gh.Repo, "/")
if len(parts) < 2 {
return parts[0], ""
Author
Owner

Realistically this could probably even error or something, but I'm fairly sure it would cause issues elsewhere anyways, so I left it simple.

Realistically this could probably even error or something, but I'm fairly sure it would cause issues elsewhere anyways, so I left it simple.
delvh reviewed 2023-07-15 21:59:32 +00:00
@ -126,0 +148,4 @@
milestones, _, err := client.Issues.ListMilestones(ctx, owner, repo, &github.MilestoneListOptions{
State: "all",
ListOptions: github.ListOptions{
PerPage: 100,
Owner

Please have a look at my diff that fixes the problem in the most common cases (basically always):

diff --git a/service/github.go b/service/github.go
index b1bbbdb..4b6873e 100644
--- a/service/github.go
+++ b/service/github.go
@@ -150,6 +150,8 @@ func (gh *GitHub) milestoneNum(ctx context.Context, client *github.Client) (int,
                ListOptions: github.ListOptions{
                        PerPage: 100,
                },
+               Sort: "due_on",
+               Direction: "desc",
        })
        if err != nil {
                return 0, err

Please have a look at my diff that fixes the problem in the most common cases (basically always): ```diff diff --git a/service/github.go b/service/github.go index b1bbbdb..4b6873e 100644 --- a/service/github.go +++ b/service/github.go @@ -150,6 +150,8 @@ func (gh *GitHub) milestoneNum(ctx context.Context, client *github.Client) (int, ListOptions: github.ListOptions{ PerPage: 100, }, + Sort: "due_on", + Direction: "desc", }) if err != nil { return 0, err ```
Author
Owner

Applied with modifications to loop (unlikely, but may as well for completeness)

Applied with modifications to loop (unlikely, but may as well for completeness)
delvh marked this conversation as resolved
jolheiser force-pushed issue-search from 41f3e3b8f0 to 5b87d1331c 2023-07-16 02:03:38 +00:00 Compare
delvh reviewed 2023-07-16 08:03:20 +00:00
@ -46,1 +58,3 @@
result, _, err := gh.client.Search.Issues(ctx, query, &github.SearchOptions{
result, _, err := gh.client.Issues.ListByRepo(ctx, owner, repo, &github.IssueListByRepoOptions{
Milestone: strconv.Itoa(milestoneNum),
State: "closed",
Owner

What about PRs that were closed, not merged, and still assigned to the milestone?
Aren't they false-positives?

What about PRs that were closed, not merged, and still assigned to the milestone? Aren't they false-positives?
@ -96,1 +114,3 @@
result, _, err := gh.client.Search.Issues(ctx, query, &github.SearchOptions{
result, _, err := gh.client.Issues.ListByRepo(ctx, owner, repo, &github.IssueListByRepoOptions{
Milestone: strconv.Itoa(milestoneNum),
State: "closed",
Owner

See above

See above
Author
Owner

@delvh Good catch, however unfortunately there's no good way to do this.

If I use the PR List endpoint, there's no way to specify a milestone.
The only other option is to use the merge status endpoint for every PR in the list, which might work but is going to be expensive to query for each item.

I wonder if it's finally time to use the graphql api for this... 🤢

@delvh Good catch, however unfortunately there's no good way to do this. If I use the PR List endpoint, there's no way to specify a milestone. The only other option is to use the merge status endpoint for every PR in the list, which might work but is going to be expensive to query for each item. I wonder if it's finally time to use the graphql api for this... 🤢
delvh approved these changes 2023-07-20 09:59:13 +00:00
delvh left a comment
Owner

Approving despite the bug at the moment.

Approving despite the bug at the moment.
lunny merged commit 3d93c3a0cd into main 2023-07-20 10:08:50 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/changelog#78
No description provided.