Open SimonLab opened 6 years ago
because of:
We also need to filter the list of issues that we get from Github to only keep the "real" issues and exclude the PRs
@SimonLab PRs deserve their own "Story". they are classified as "issues" by GitHub. and we do want to track the comments in them eventually ...
@nelsonic see #30 I'll update the issue with more details (github api documentation link and any other info that might be useful to help us implement this issue)
The Github API use pagination when returning result, see: https://developer.github.com/v3/guides/traversing-with-pagination/
The information of the pagination will be in the header of the reply.
page
query parameterI copy/paste taking inspiration from Tentacat regex to get the Link header data intead of spliting/filter the headers:
https://github.com/edgurgel/tentacat/blob/d4c9ba7d8dbc4825d43e5f4a5b0ce7698688b0e4/lib/tentacat.ex#L141-L151
Trying to get the total number of pages with the following function:
defp last_page(headers) do
for {"Link", link_header} <- headers, links <- String.split(link_header, ",") do
Regex.named_captures(~r/<(?<link>.*)>;\s*rel=\"(?<rel>.*)\"/, links)
|> case do
%{"link" => link, "rel" => "last"} -> link
_ -> nil
end
end
|> Enum.filter(&(not is_nil(&1)))
|>List.first
|>Regex.named_captures(~r/page=(?<page>.*)/)
end
My last Regex is not correct and can't manage to match for example the following url:
The arguments of the Regex.named_captures
are on the wrong order! :face_with_head_bandage:
regex first then string
The function to get all the closed issues has been added to the project with #33 however as we don't save yet the data in Postgres and S3 and we don't have the UI linked to the data this issue can't be directly tested yet. At the end this issue is more a technicall issue. I'll remove the awaiting-review label and add a please-test later one when a way to see that closed issue have been collected (app UI or AWS S3 UI) has been added
Putting blocker label on this issue as it can't be progressed until it is testable with the UI and postgres data.
This can now be tested. I can access one of my closed issues: However it's not very clear that the issue is closed from the UI, we might need to find a way to indicate this.
@SimonLab - perhaps we should open a new issue to create UI resemble something like the github UI: Is that what you were thinking?
From: https://developer.github.com/v3/issues/#list-issues-for-a-repository To get the list of issues of a repository we need to send a GET request to
/repos/:owner/:repo/issues
By adding the
state
query parameter to the query we can choose to get all the issues and not just the open ones:We already have the
get_issues
function: https://github.com/dwyl/github-backup/blob/295ee9e7cf0bc9b5f6d88e89601c5341a2351956/lib/app_web/controllers/github_api/http_client.ex#L47-L52 We need to update this function to add thestate
query parameter with the valueall
ref: