Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#1025 #1239

Merged
merged 20 commits into from
Sep 30, 2021
Merged

Feature/#1025 #1239

merged 20 commits into from
Sep 30, 2021

Conversation

bloslo
Copy link
Contributor

@bloslo bloslo commented Sep 24, 2021

Description

Add GHIssueQueryBuilder. Closes #1025.

I didn't use the GHIssueQueryBuilder as a base class for the GHPullRequestQueryBuilder as suggested in the issue because of the different query parameters the two endpoints list.

I was wondering should the listIssues method in GHRepository be marked for deprecation? Similar to the listPullRequests method in the same class.

@codecov
Copy link

codecov bot commented Sep 24, 2021

Codecov Report

Merging #1239 (b309785) into main (2dc736a) will increase coverage by 0.14%.
The diff coverage is 92.30%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1239      +/-   ##
============================================
+ Coverage     77.28%   77.42%   +0.14%     
- Complexity     1889     1899      +10     
============================================
  Files           188      189       +1     
  Lines          5943     5972      +29     
  Branches        328      327       -1     
============================================
+ Hits           4593     4624      +31     
+ Misses         1152     1150       -2     
  Partials        198      198              
Impacted Files Coverage Δ
src/main/java/org/kohsuke/github/GHRepository.java 68.08% <50.00%> (+0.11%) ⬆️
...n/java/org/kohsuke/github/GHIssueQueryBuilder.java 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2dc736a...b309785. Read the comment docs.

@bitwiseman
Copy link
Member

bitwiseman commented Sep 24, 2021

@bloslo
Please write your tests so that they do not reduce existing code coverage (similar to what I did with your previous PR). Also make sure you have tests covering as many of the added paths as possible. If you can't cover all of them, please add comments (on this PR, not in the code) for why those paths can't be covered.

I've invited you to the hub4j-test-org to ensure you can re-record test data as needed.

@bitwiseman
Copy link
Member

I was wondering should the listIssues method in GHRepository be marked for deprecation? Similar to the listPullRequests method in the same class.

Yeah, probably.

I'm also wondering if GHQueryBuilder should extend PagedIterable. That would remove the need to call list() or end up with query.list().asList(). But that is another issue/PR.

Copy link
Member

@bitwiseman bitwiseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the second round of feedback. I took a closer look this time around and saw a couple things I missed. The label change is pretty much as written in the suggestions. The class structure change, the suggested code is for clarity and there are a bunch more changes to be made.

Thanks for you patience and perseverance.


public class GHIssueQueryBuilder extends GHQueryBuilder<GHIssue> {
private final GHRepository repo;
private List<String> labels = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private List<String> labels = new ArrayList<>();
private final List<String> labels = new ArrayList<>();

Comment on lines 152 to 153
return req.with("labels", labels.stream().collect(Collectors.joining(",")))
.withUrlPath(repo.getApiTailUrl("issues"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return req.with("labels", labels.stream().collect(Collectors.joining(",")))
.withUrlPath(repo.getApiTailUrl("issues"))
return req.withUrlPath(repo.getApiTailUrl("issues"))

@@ -2,7 +2,7 @@
"id": "a70d05ac-5820-4749-8318-e422f0f6eaf5",
"name": "repos_hub4j_github-api_issues",
"request": {
"url": "/repos/hub4j/github-api/issues?state=closed",
"url": "/repos/hub4j/github-api/issues?state=closed&labels=",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&labels= is a no-op parameter and should not be present.

Suggested change
"url": "/repos/hub4j/github-api/issues?state=closed&labels=",
"url": "/repos/hub4j/github-api/issues?state=closed",

@@ -2,7 +2,7 @@
"id": "b87318fd-8120-4fad-8c4d-553dafde3319",
"name": "repos_hub4j_github-api_issues",
"request": {
"url": "/repos/hub4j/github-api/issues?state=closed",
"url": "/repos/hub4j/github-api/issues?state=closed&labels=",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"url": "/repos/hub4j/github-api/issues?state=closed&labels=",
"url": "/repos/hub4j/github-api/issues?state=closed",

"id": "92abb44d-1298-496e-a8e9-ae447ffc68a1",
"name": "repos_hub4j-test-org_testqueryissues_issues",
"request": {
"url": "/repos/hub4j-test-org/testQueryIssues/issues?state=all&mentioned=bloslo&since=1970-01-19T21%3A26%3A51Z&sort=comments&direction=asc&labels=",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"url": "/repos/hub4j-test-org/testQueryIssues/issues?state=all&mentioned=bloslo&since=1970-01-19T21%3A26%3A51Z&sort=comments&direction=asc&labels=",
"url": "/repos/hub4j-test-org/testQueryIssues/issues?state=all&mentioned=bloslo&since=1970-01-19T21%3A26%3A51Z&sort=comments&direction=asc",

Comment on lines 296 to 297
List<GHIssue> openBugIssues = gitHub.getOrganization("hub4j-test-org")
.getRepository("testQueryIssues")
Copy link
Member

@bitwiseman bitwiseman Sep 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't need to request the repo again each time. Once you make this change, re-record to test data.

Suggested change
List<GHIssue> openBugIssues = gitHub.getOrganization("hub4j-test-org")
.getRepository("testQueryIssues")
final GHRepository repo = gitHub.getOrganization("hub4j-test-org")
.getRepository("testQueryIssues");
List<GHIssue> openBugIssues = repo

src/test/java/org/kohsuke/github/AppTest.java Show resolved Hide resolved
src/test/java/org/kohsuke/github/AppTest.java Show resolved Hide resolved
Comment on lines 308 to 309
List<GHIssue> openIssuesWithAssignee = gitHub.getOrganization("hub4j-test-org")
.getRepository("testQueryIssues")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List<GHIssue> openIssuesWithAssignee = gitHub.getOrganization("hub4j-test-org")
.getRepository("testQueryIssues")
List<GHIssue> openIssuesWithAssignee = repo

Comment on lines 317 to 318
List<GHIssue> allIssuesSince = gitHub.getOrganization("hub4j-test-org")
.getRepository("testQueryIssues")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List<GHIssue> allIssuesSince = gitHub.getOrganization("hub4j-test-org")
.getRepository("testQueryIssues")
List<GHIssue> allIssuesSince = repo

@bloslo bloslo requested a review from bitwiseman September 28, 2021 15:55
Copy link
Member

@bitwiseman bitwiseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@bitwiseman bitwiseman merged commit 996170a into hub4j:main Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add GHIssueQueryBuilder to allow better filtering of issue queries
2 participants