Skip to content

Commit

Permalink
GitHub :)
Browse files Browse the repository at this point in the history
  • Loading branch information
j0k3r committed Apr 20, 2017
1 parent be5895f commit a98f32c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
[![Scrutinizer Status](https://scrutinizer-ci.com/g/j0k3r/banditore/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/j0k3r/banditore/?branch=master)
[![Say Thanks !](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/j0k3r)

Banditore retrieves new releases from your Github starred repositories and put them in a RSS feed, just for you.
Banditore retrieves new releases from your GitHub starred repositories and put them in a RSS feed, just for you.

![](https://i.imgur.com/XDCWLJV.png)

## Requirements

- PHP >= 5.5.9 (with `pdo_mysql`)
- MySQL >= 5.7
- Redis (to cache requests to the Github API)
- Redis (to cache requests to the GitHub API)
- [RabbitMQ](https://www.rabbitmq.com/), which is optional (see below)
- [Supervisor](http://supervisord.org/) (only if you use RabbitMQ)

Expand All @@ -27,7 +27,7 @@ Banditore retrieves new releases from your Github starred repositories and put t
git clone https://github.com/j0k3r/banditore.git
```

2. [Register a new OAuth Github application](https://github.com/settings/applications/new) and get the _Client ID_ & _Client Secret_ for the next step (for the _Authorization callback URL_ put `http://127.0.0.1:8000/callback`)
2. [Register a new OAuth GitHub application](https://github.com/settings/applications/new) and get the _Client ID_ & _Client Secret_ for the next step (for the _Authorization callback URL_ put `http://127.0.0.1:8000/callback`)

3. Install dependencies using [Composer](https://getcomposer.org/download/) and define your parameter during the installation

Expand Down Expand Up @@ -149,10 +149,10 @@ After retrieving the tag, we need to retrieve the commit to get these informatio
> Check a commit from the previous tag list as example: https://api.github.com/repos/swarrot/SwarrotBundle/commits/84c7c57622e4666ae5706f33cd71842639b78755
### Github Client Discovery
### GitHub Client Discovery
This is the most important piece of the app. One thing that I ran though is hitting the rate limit on Github.
The rate limit for a given authenticated client is 5.000 calls per hour. This limit is **never** reached when looking for new release (thanks to the [conditional requests](https://developer.github.com/v3/#conditional-requests) of the Github API) on a daily basis.
This is the most important piece of the app. One thing that I ran though is hitting the rate limit on GitHub.
The rate limit for a given authenticated client is 5.000 calls per hour. This limit is **never** reached when looking for new release (thanks to the [conditional requests](https://developer.github.com/v3/#conditional-requests) of the GitHub API) on a daily basis.
But when new user sign in, we need to sync all its starred repositories and also all their releases / tags. And here come the gourmand part:
- one call for the list of release
Expand All @@ -165,9 +165,9 @@ Let's say the repo:
And keep in mind that some repos got also 1.000+ tags (!!).
To avoid hitting the limit in such case and wait 1 hour to be able to make requests again I created the [Github Client Discovery class](src/AppBundle/Github/ClientDiscovery.php).
To avoid hitting the limit in such case and wait 1 hour to be able to make requests again I created the [GitHub Client Discovery class](src/AppBundle/Github/ClientDiscovery.php).
It aims to find the best client with enough rate limit remain (defined as 50).
- it first checks using the Github OAuth app
- then it checks using all user Github token
- it first checks using the GitHub OAuth app
- then it checks using all user GitHub token
Which means, if you have 5 users on the app, you'll be able to make (1 + 5) x 5.000 = 25.000 calls per hour
4 changes: 2 additions & 2 deletions app/Resources/views/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Banditore retrieves new releases from your Github starred repositories and put them in a RSS feed, just for you.">
<meta name="description" content="Banditore retrieves new releases from your GitHub starred repositories and put them in a RSS feed, just for you.">
<link rel="icon" type="image/icon" href="{{ asset('favicon.ico') }}" />
<link rel="shortcut icon" type="image/ico" href="{{ asset('favicon.ico') }}" />

Expand Down Expand Up @@ -36,7 +36,7 @@
<div class="pure-u-1 pure-u-md-1-2">
<div class="pure-menu pure-menu-horizontal menu-can-transform">
<ul class="pure-menu-list">
<li class="pure-menu-item"><a href="https://github.com/j0k3r/banditore" class="pure-menu-link">View it on Github</a></li>
<li class="pure-menu-item"><a href="https://github.com/j0k3r/banditore" class="pure-menu-link">View it on GitHub</a></li>
<li class="pure-menu-item"><a href="{{ url('stats') }}" class="pure-menu-link">Stats</a></li>
{% if app.user -%}
<li class="pure-menu-item"><a href="{{ url('logout') }}" class="pure-menu-link">Logout ({{ app.user.username }})</a></li>
Expand Down
4 changes: 2 additions & 2 deletions app/Resources/views/default/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="splash-container middle-content">
<div class="splash">
<h1 class="splash-head">Get new release in your RSS!</h1>
<p>We gather new releases from your starred Github repositories and generate a RSS feed with them.</p>
<p>We gather new releases from your starred GitHub repositories and generate a RSS feed with them.</p>
<p>Just for you.</p>
<p>
<a href="{{ url('github_connect') }}" class="pure-button pure-button-primary">Try it!</a>
Expand Down Expand Up @@ -63,7 +63,7 @@
<h2 class="content-head is-center content-head-ribbon">How it works</h2>

<div class="pure-u-1 pure-u-md-1-2 pure-u-lg-3-5">
<h4 class="content-head-ribbon">Retrieve starred repositories from your Github account</h4>
<h4 class="content-head-ribbon">Retrieve starred repositories from your GitHub account</h4>
<p>
When you first login, we retrieve minimal information from you (name, username &amp; avatar).
Then we fetch your stars &amp; their associated repository.
Expand Down
2 changes: 1 addition & 1 deletion tests/AppBundle/Controller/DefaultControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testDashboard()
$this->assertSame(200, $this->client->getResponse()->getStatusCode());

$menu = $crawler->filter('.menu-wrapper')->text();
$this->assertContains('View it on Github', $menu, 'Link to Github is here');
$this->assertContains('View it on GitHub', $menu, 'Link to GitHub is here');
$this->assertContains('Logout (admin)', $menu, 'Info about logged in user is here');

$aside = $crawler->filter('aside.feed')->text();
Expand Down

0 comments on commit a98f32c

Please sign in to comment.