The
trending section on GitHub displays a list of projects that are actively gaining stars during the day, week, or month. The most interesting things that appear in open source for each programming language are always on this list. Today I want to share a way to subscribe to the emergence of new "star" projects using GitHub notifications and not to miss out on anything useful for myself.
What it looks like
For the subscription, a special
github-trending-repos repository is used. Each issue in this repository corresponds to one programming language:
You enter issues you are interested in and subscribe to the discussion using
the GitHub notification mechanism . As soon as a new popular repository appears in the selected programming language, a special bot will post a comment. At this point, you will receive a notification in the GitHub web interface or by mail (depending on your settings). In the web interface, it looks like this:
')
A click on the notification opens the added comment, which contains a link to the project, a short description and the number of stars received:
How it works
Once an hour, a script is run on the server, which, through the
GitHub API, avoids all the issues. For each programming language, a list of currently popular repositories is loaded. Then from this list are excluded repositories that are already mentioned in the comments to the issue. As a result, there are only freshly added projects. Text is formed from them and a new comment is added. Subscribers are automatically notified.
Features of the implementation
- To run the script on a schedule, Travis CI had to abandon in favor of CircleCI . Reason: Travis CI can run at most once a day , and CircleCI allows flexible configuration of launches via cron syntax and even starts every minute.
- GitHub does not provide an API for getting “trending” repositories. Therefore, the list is formed directly from the HTML code of the page by selectors. To solve this problem under Node.js, I used Cheerio . It is enough to feed him the URL and use the
$()
function to select the desired page elements. - When working with the GitHub API, you need to remember about pagination - by default, a maximum of 30 elements are returned in the response. Data on the number of pages and links to navigate through them are transmitted in the HTTP Link header. In order not to parse it manually, I used the ready-made JavaScript library parse-link-header .
Conclusion
For me, this method of tracking trends was quite convenient. GitHub notifications are familiar and unobtrusive. And I stay up to date with all the new products. Try it and you will be glad if you find it useful.
Link to the project . Ideas and suggestions are welcome!
UPDATE:Many complained that notifications came too often. Therefore, I changed the schedule: now checking daily trends only happens once a day and checking weekly trends only on Fridays.