-
-
Notifications
You must be signed in to change notification settings - Fork 299
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
comits/ahead/behind/status #30
base: master
Are you sure you want to change the base?
Conversation
Something is resulting in this error:
And, there seem to be two status columns. Also, kind of related & kind of unrelated, finally there's a concern about the api rate limit and how we should handle this. Maybe we allow an input box to provide personal access token. Thoughts? |
How did you got that warning ? didn't saw it when testing. |
Thanks @floatas for the update.I will see if I can replicate that again |
Here's a screenshot of the error message:
Seems pretty reliably reproducible, as I got it both times I launched the app. However, it seems that with some sorting going on (I clicked to sort by "ahead" in descending order before I clicked "Find"), I get rate-limited from just one click of the "Find" button and nothing more. Perhaps this should be filed as another issue. |
Maybe this is related to rate limiting. Can you share which repository you tried ? |
maybe ask github to extend their API? maybe use v4 API with graphQL? code sample with basic auth: let username = 'your_github_username'
let password = 'your_github_password'
let headers = new Headers({
'Authorization': 'Basic '+btoa(username+":"+password), // base64
'Content-Type': 'application/json',
'Accept': 'application/json',
})
fetch('https://api.github.com/graphql', {
method: 'POST',
headers: headers,
body: JSON.stringify({
// get schema introspection
query: "{__schema{types{name,kind,description,fields{name}}}}"})
})
.then(r => r.json())
.then(data => console.log('data returned:', data)) workaround with v3 API: var fetch = require('fetch-retry');
fetch(url, {
// retry on status 403 Forbidden
retryOn: [403],
// Exponential backoff
retryDelay: function(attempt, error, response) {
return Math.pow(2, attempt) * 1000; // 1000, 2000, 4000
},
})
.then(function(response) {
return response.json();
})
.then(function(json) {
// do something with the result
console.log(json);
});
same here original repo is https://github.com/rugantio/fbcrawl with 130 forks active-forks says "Showing 1 to 10 of 100 entries" alert message is
javascript console, same error repeats for 40 forks
forks, forks, forks, forks, .... |
Even with v4 and authentication you can get ~500 forks per hour due to limitations. |
sample code for the github fork browser "active-forks" techgaun/active-forks#30
in v4 we get 100 forks per query
we can also get more data on commits, if that helps to compare the only downside is, we need authentication here my graphQL string query (
$repoOwner: String!,
$repoName: String!,
$refOrder: RefOrder!,
$forksPerPage: Int!, # forks per page
$forksCursor: String, # forks pagination cursor
) {
repository (
owner: $repoOwner, # select original repo
name: $repoName,
) {
nameWithOwner # owner/name
pushedAt # modify time
stargazers {
totalCount # github stars
}
forkCount
refs(refPrefix: "refs/", first: 100) {
nodes {
target {
... on Commit {
history(first: 5) {
totalCount # original commits
}}}}}
forks(
first: $forksPerPage, # select fork repos
after: $forksCursor,
) {
totalCount
pageInfo {
hasNextPage # fork pagination
endCursor
}
edges{
#cursor # fork cursor
node{
... on Repository {
nameWithOwner # fork owner/name
pushedAt # fork modify time
stargazers {
totalCount # fork github stars
}
refs(refPrefix:"refs/",orderBy:$refOrder,first:1){
nodes{
... on Ref{
target{
... on Commit{
history(first:10){
totalCount # fork commits
}}}}}}}}}}}} |
using v3 API when Promise.all(data.map(async (fork) => {
if (fork.pushed_at < fork.created_at) {
// fork is empty
return
}
fetch(`https://api.github.com/repos/${repo}/compare/master...${fork.owner.login}:master`) |
Any progress on this? |
no progress. the github v4 graphql api is not ideal for this scenario cos .... the fields ahead/behind are not served in the repo metadata, and must be calculated from commit data. TODO post a feature request batching multiple queries into one request is messy, cos the github graphql server does not support standard query batching, so we need a workaround with field aliases, like query1 query2 etc, to imitate an sql "in" operator - again, a better serverconfig/api would help. also huge queries run into server limits so we need error handling also i found no way to sort or filter commits on server side, so you need to paginate through all the commits, until you find the "branchoff" commit, previously found by main commits x fork date |
Sounds mighty ugly. So many repositories get abandoned, even popular stuff and it's a pain to sort through dozens if not hundreds of forks to find something that works or is maintained. |
Hi, does anybody contacted the company github respectively Microsoft about how useful techgaun/active-forks is for the community (or how useful it would be if everybody knew about it)? If they want to deliver best service for their customers/users, they should
|
Sorry for being away from the issue around this and this PR for such a long time. And, thanks @haimivan for creating topic on gh. I'll also try to re-understand and try to come up with possible solution around this. |
A related implementation is available (Source code) a GitHub token is asked, then a sortable table with last commit date and a diff is displayed. |
Initial implementation for #17 simply do request for each for to fetch information.