News for hackers. Stuff that matters.
Re:Show HN: CodeHalf – Write Code Everyday, new design and n... by nosefrog on Monday December 28, 2015 @07:54AM (#10800894)
When I looked into this, I used the GitHub Events API to get all of the events the user took[0], and then filtered by Push Events. Push Events consist of commits to a repo, and I used the GetCommit Repository API [1] to get more metadata for the commit.

If you save the ETag from the Events API and pass it back in your next request, you'll get a 304 response if the data hasn't changed and it won't hit your request limit.

You'll want to poll the user's events periodically, and store that data in a database. It's too slow to ping GitHub's API every time, because there isn't a single API that provides exactly what you need.

Check out FetchRecentCommits[2] for how I hit the GitHub API, and UpdateUserCommits[3] and CreateCommit[4] for how I extract the data from the commit and store it in the database.

Good luck! Keep me updated, my username is in my profile :)

[0] https://developer.github.com/v3/activity/events/#list-public...

[1] https://developer.github.com/v3/repos/commits/#get-a-single-...

[2] https://github.com/samertm/githubstreaks/blob/master/model.g...

[3] https://github.com/samertm/githubstreaks/blob/master/model.g...

[4] https://github.com/samertm/githubstreaks/blob/master/model.g...

There are no comments on this comment yet.