Skip to content

Commit

Permalink
Push down issue and pull state filter and show all issues by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nineinchnick committed Jul 5, 2021
1 parent 774417d commit 1182d34
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ private Collection<? extends List<?>> getPulls(RestTableHandle table)
String repo = (String) filter.getFilter((RestColumnHandle) columns.get("repo"), constraint);
requirePredicate(owner, "pulls.owner");
requirePredicate(repo, "pulls.repo");
// TODO allow filtering by state (many, comma separated, or all), requires https://github.com/nineinchnick/trino-rest/issues/30
String state = (String) filter.getFilter((RestColumnHandle) columns.get("state"), constraint, "all");
SortItem sortOrder = getSortItem(table);
return getRowsFromPages(
page -> service.listPulls(
Expand All @@ -1197,7 +1197,7 @@ private Collection<? extends List<?>> getPulls(RestTableHandle table)
page,
sortOrder.getName(),
sortOrder.getSortOrder().isAscending() ? "asc" : "desc",
"all"),
state),
item -> {
item.setOwner(owner);
item.setRepo(repo);
Expand Down Expand Up @@ -1329,6 +1329,7 @@ private Collection<? extends List<?>> getIssues(RestTableHandle table)
requirePredicate(owner, "issues.owner");
requirePredicate(repo, "issues.repo");
String since = (String) filter.getFilter((RestColumnHandle) columns.get("updated_at"), constraint, "1970-01-01T00:00:00Z");
String state = (String) filter.getFilter((RestColumnHandle) columns.get("state"), constraint, "all");
SortItem sortOrder = getSortItem(table);
return getRowsFromPages(
page -> service.listIssues(
Expand All @@ -1339,6 +1340,7 @@ private Collection<? extends List<?>> getIssues(RestTableHandle table)
page,
sortOrder.getName(),
sortOrder.getSortOrder().isAscending() ? "asc" : "desc",
state,
since),
item -> {
item.setOwner(owner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Call<List<Issue>> listIssues(
@Query("page") int page,
@Query("sort") String sort,
@Query("direction") String direction,
@Query("state") String state,
@Query("since") String since);

@Headers("accept: application/vnd.github.v3+json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public Map<String, FilterType> getSupportedFilters()
return ImmutableMap.of(
"owner", FilterType.EQUAL,
"repo", FilterType.EQUAL,
"updated_at", FilterType.GREATER_THAN_EQUAL);
"updated_at", FilterType.GREATER_THAN_EQUAL,
"state", FilterType.EQUAL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public Map<String, FilterType> getSupportedFilters()
{
return ImmutableMap.of(
"owner", FilterType.EQUAL,
"repo", FilterType.EQUAL);
"repo", FilterType.EQUAL,
"state", FilterType.EQUAL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public Block getPage(
(int) page,
"updated",
"asc",
"all",
ISO_LOCAL_DATE_TIME.format(fromTrinoTimestamp(since)) + "Z").execute();
if (response.code() == HTTP_NOT_FOUND) {
return null;
Expand Down

0 comments on commit 1182d34

Please sign in to comment.