Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GHIssue#queryComments, with a since() filter
- Loading branch information
Showing
84 changed files
with
3,355 additions
and
1,621 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/org/kohsuke/github/GHIssueCommentQueryBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.kohsuke.github; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* Builds a query for listing comments on an issue. | ||
* <p> | ||
* Call various methods that set the filter criteria, then the {@link #list()} method to actually retrieve the comments. | ||
* | ||
* <pre> | ||
* GHIssue issue = ...; | ||
* for (GHIssueComment comment : issue.queryComments().since(x).list()) { | ||
* ... | ||
* } | ||
* </pre> | ||
* | ||
* @author Yoann Rodiere | ||
* @see GHIssue#queryComments() GHIssue#queryComments() | ||
* @see <a href="https://docs.github.com/en/rest/issues/comments#list-issue-comments">List issue comments</a> | ||
*/ | ||
public class GHIssueCommentQueryBuilder { | ||
private final Requester req; | ||
private final GHIssue issue; | ||
|
||
GHIssueCommentQueryBuilder(GHIssue issue) { | ||
this.issue = issue; | ||
this.req = issue.root().createRequest().withUrlPath(issue.getIssuesApiRoute() + "/comments"); | ||
} | ||
|
||
/** | ||
* Only comments created/updated after this date will be returned. | ||
* | ||
* @param date | ||
* the date | ||
* @return the query builder | ||
*/ | ||
public GHIssueCommentQueryBuilder since(Date date) { | ||
req.with("since", GitHubClient.printDate(date)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Only comments created/updated after this timestamp will be returned. | ||
* | ||
* @param timestamp | ||
* the timestamp | ||
* @return the query builder | ||
*/ | ||
public GHIssueCommentQueryBuilder since(long timestamp) { | ||
return since(new Date(timestamp)); | ||
} | ||
|
||
/** | ||
* Lists up the comments with the criteria added so far. | ||
* | ||
* @return the paged iterable | ||
*/ | ||
public PagedIterable<GHIssueComment> list() { | ||
return req.toIterable(GHIssueComment[].class, item -> item.wrapUp(issue)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.