{"action":"created","issue":{"url":"https://api.github.com/repos/ipfs/get-gh-contributors/issues/8","repository_url":"https://api.github.com/repos/ipfs/get-gh-contributors","labels_url":"https://api.github.com/repos/ipfs/get-gh-contributors/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/ipfs/get-gh-contributors/issues/8/comments","events_url":"https://api.github.com/repos/ipfs/get-gh-contributors/issues/8/events","html_url":"https://github.com/ipfs/get-gh-contributors/issues/8","id":237368427,"node_id":"MDU6SXNzdWUyMzczNjg0Mjc=","number":8,"title":"Count with all sorts of contributions","user":{"login":"whyrusleeping","id":1243164,"node_id":"MDQ6VXNlcjEyNDMxNjQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1243164?v=4","gravatar_id":"","url":"https://api.github.com/users/whyrusleeping","html_url":"https://github.com/whyrusleeping","followers_url":"https://api.github.com/users/whyrusleeping/followers","following_url":"https://api.github.com/users/whyrusleeping/following{/other_user}","gists_url":"https://api.github.com/users/whyrusleeping/gists{/gist_id}","starred_url":"https://api.github.com/users/whyrusleeping/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whyrusleeping/subscriptions","organizations_url":"https://api.github.com/users/whyrusleeping/orgs","repos_url":"https://api.github.com/users/whyrusleeping/repos","events_url":"https://api.github.com/users/whyrusleeping/events{/privacy}","received_events_url":"https://api.github.com/users/whyrusleeping/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2017-06-20T22:57:43Z","updated_at":"2018-12-12T07:36:53Z","closed_at":null,"author_association":"MEMBER","body":"Not sure whats wrong exactly, but the code in this repo doesnt produce the right output (its missing a lot of people).\r\n\r\nHeres the go code i wrote that seems to be correct:\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n        \"context\"\r\n        \"encoding/json\"\r\n        \"fmt\"\r\n        \"github.com/google/go-github/github\"\r\n        \"golang.org/x/oauth2\"\r\n        \"io/ioutil\"\r\n        \"net/http\"\r\n        \"os\"\r\n        \"strings\"\r\n)\r\n\r\nvar authtok = \"YOUR GITHUB AUTH TOKEN\"\r\nvar ghurl = \"https://api.github.com\"\r\n\r\nvar cli = oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(&oauth2.Token{AccessToken: authtok}))\r\n\r\nfunc getBlob(res string) ([]byte, error) {\r\n        fname := \"data/\" + strings.Replace(res, \"/\", \"-\", -1)\r\n        if _, err := os.Stat(fname); err == nil {\r\n                return ioutil.ReadFile(fname)\r\n        }\r\n\r\n        req, err := http.NewRequest(\"GET\", ghurl+res, nil)\r\n        if err != nil {\r\n                panic(err)\r\n        }\r\n\r\n        resp, err := cli.Do(req)\r\n        if err != nil {\r\n                return nil, err\r\n        }\r\n\r\n        if resp.StatusCode != 200 {\r\n                return nil, fmt.Errorf(\"%s failed: %s\", res, resp.Status)\r\n        }\r\n\r\n        data, err := ioutil.ReadAll(resp.Body)\r\n        if err != nil {\r\n                return nil, err\r\n        }\r\n\r\n        err = ioutil.WriteFile(fname, data, 0644)\r\n        if err != nil {\r\n                return nil, err\r\n        }\r\n\r\n        return data, nil\r\n}\r\n\r\nfunc getAllRepos(org string) []github.Repository {\r\n        var repos []github.Repository\r\n        for i := 1; i < 100; i++ {\r\n                data, err := getBlob(fmt.Sprintf(\"/orgs/%s/repos?page=%d&per_page=100\", org, i))\r\n                if err != nil {\r\n                        panic(err)\r\n                }\r\n\r\n                var these []github.Repository\r\n                if err := json.Unmarshal(data, &these); err != nil {\r\n                        panic(err)\r\n                }\r\n                repos = append(repos, these...)\r\n                if len(these) < 100 {\r\n                        break\r\n                }\r\n        }\r\n        return repos\r\n}\r\n\r\nfunc getAllPRs(repo github.Repository) []github.PullRequest {\r\n        var all []github.PullRequest\r\n        for i := 1; i < 100; i++ {\r\n                data, err := getBlob(fmt.Sprintf(\"/repos/%s/%s/pulls?page=%d&per_page=100&state=all\", \"ipfs\", repo.GetName(), i))\r\n                if err != nil {\r\n                        panic(err)\r\n                }\r\n\r\n                var these []github.PullRequest\r\n                if err := json.Unmarshal(data, &these); err != nil {\r\n                        panic(err)\r\n                }\r\n                all = append(all, these...)\r\n\r\n                if len(these) < 100 {\r\n                        break\r\n                }\r\n        }\r\n\r\n        return all\r\n}\r\n\r\nfunc getAllIssues(org string, repo github.Repository) []github.Issue {\r\n        var all []github.Issue\r\n        for i := 1; i < 100; i++ {\r\n                data, err := getBlob(fmt.Sprintf(\"/repos/%s/%s/issues?page=%d&per_page=100&state=all\", org, repo.GetName(), i))\r\n                if err != nil {\r\n                        panic(err)\r\n                }\r\n\r\n                var these []github.Issue\r\n                if err := json.Unmarshal(data, &these); err != nil {\r\n                        panic(err)\r\n                }\r\n                all = append(all, these...)\r\n\r\n                if len(these) < 100 {\r\n                        break\r\n                }\r\n        }\r\n\r\n        return all\r\n}\r\n\r\nfunc getAllComments(org, repo string, issue github.Issue) []github.IssueComment {\r\n        var all []github.IssueComment\r\n        for i := 1; i < 100; i++ {\r\n                data, err := getBlob(fmt.Sprintf(\"/repos/%s/%s/issues/%d/comments?page=%d&per_page=100&state=all\", org, repo, issue.GetNumber(), i))\r\n                if err != nil {\r\n                        panic(err)\r\n                }\r\n\r\n                var these []github.IssueComment\r\n                if err := json.Unmarshal(data, &these); err != nil {\r\n                        panic(err)\r\n                }\r\n                all = append(all, these...)\r\n\r\n                if len(these) < 100 {\r\n                        break\r\n                }\r\n        }\r\n\r\n        return all\r\n}\r\n\r\ntype output struct {\r\n        Url      string `json:\"url\"`\r\n        Photo    string `json:\"photo\"`\r\n        Username string `json:\"username\"`\r\n}\r\n\r\nfunc main() {\r\n        allpeople := make(map[string]*github.User)\r\n        for _, org := range []string{\"ipfs\", \"ipld\", \"multiformats\", \"libp2p\", \"orbitdb\"} {\r\n                repos := getAllRepos(org)\r\n\r\n                for _, repo := range repos {\r\n                        issues := getAllIssues(org, repo)\r\n                        for _, issue := range issues {\r\n                                issue.Repository = &repo\r\n                                allpeople[*issue.User.Login] = issue.User\r\n                                comments := getAllComments(org, repo.GetName(), issue)\r\n                                for _, c := range comments {\r\n                                        allpeople[c.User.GetLogin()] = c.User\r\n                                }\r\n                        }\r\n                }\r\n        }\r\n\r\n        var out []output\r\n        for k, v := range allpeople {\r\n                out = append(out, output{\r\n                        Url:      v.GetHTMLURL(),\r\n                        Photo:    v.GetAvatarURL(),\r\n                        Username: k,\r\n                })\r\n        }\r\n        enc := json.NewEncoder(os.Stdout)\r\n        enc.SetIndent(\"\", \"  \")\r\n        if err := enc.Encode(out); err != nil {\r\n                panic(err)\r\n        }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/ipfs/get-gh-contributors/issues/comments/446490976","html_url":"https://github.com/ipfs/get-gh-contributors/issues/8#issuecomment-446490976","issue_url":"https://api.github.com/repos/ipfs/get-gh-contributors/issues/8","id":446490976,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NjQ5MDk3Ng==","user":{"login":"daviddias","id":1211152,"node_id":"MDQ6VXNlcjEyMTExNTI=","avatar_url":"https://avatars0.githubusercontent.com/u/1211152?v=4","gravatar_id":"","url":"https://api.github.com/users/daviddias","html_url":"https://github.com/daviddias","followers_url":"https://api.github.com/users/daviddias/followers","following_url":"https://api.github.com/users/daviddias/following{/other_user}","gists_url":"https://api.github.com/users/daviddias/gists{/gist_id}","starred_url":"https://api.github.com/users/daviddias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daviddias/subscriptions","organizations_url":"https://api.github.com/users/daviddias/orgs","repos_url":"https://api.github.com/users/daviddias/repos","events_url":"https://api.github.com/users/daviddias/events{/privacy}","received_events_url":"https://api.github.com/users/daviddias/received_events","type":"User","site_admin":false},"created_at":"2018-12-12T07:36:53Z","updated_at":"2018-12-12T07:36:53Z","author_association":"MEMBER","body":"Note to self. The go program expects a `data` folder to exist otherwise it panics"}}
{"actor":{"display_login":"daviddias"}}