Sync stats

This commit is contained in:
Brandon Keepers
2017-08-04 10:02:49 -05:00
parent 7cecbb6ca5
commit 436f7fd80c
9 changed files with 31 additions and 15 deletions

View File

@@ -9,7 +9,7 @@ organizations:
- kubernetes
- nodejs
stars: 19
installs: 48
installations: 48
author: bkeepers
repository: probot/dco
topics:

View File

@@ -3,7 +3,7 @@ title: Duplicate Issues
description: Automatically detects duplicate issues
slug: dup
stars: 15
installs: 4
installations: 4
author: MarshallOfSound
repository: MarshallOfSound/probot-issue-duplicate-detection
---

View File

@@ -4,8 +4,8 @@ description: Pull Requests for repository settings
slug: settings
topics:
- administration
stars: 121
installs: 38
stars: 123
installations: 38
author: bkeepers
repository: probot/configurer
---

View File

@@ -4,6 +4,6 @@ description: Temporarily close Issues and Pull Requests
slug: snooze
author: jbjonesjr
stars: 3
installs: 5
installations: 5
repository: jbjonesjr/probot-snooze
---

View File

@@ -9,15 +9,20 @@ topics:
- project-management
organizations:
- atom
- rails
- homebrew
- exercism
- github
- npm
- Homebrew
- fchollet
- hexojs
- apollographql
- sequelize
- hubotio
- mochajs
- nodemailer
- tldr-pages
author: bkeepers
stars: 124
installs: 305
stars: 129
installations: 98
repository: probot/stale
host: https://probot-stale.herokuapp.com
---
Automatically close stale Issues and Pull Requests that tend to accumulate during a project.

View File

@@ -4,6 +4,6 @@ description: Prevent merging of unfinished Pull Requests
slug: wip
author: gr2m
stars: 5
installs: 7
installations: 7
repository: gr2m/wip-bot
---

View File

@@ -17,7 +17,7 @@ layout: default
Add to GitHub
</a>
<div class="text-gray-light">
<div class="d-inline mr-3 tooltipped tooltipped-s" aria-label="{{ page.installs }} installations">{% octicon cloud-download width:14 class:"v-align-middle" %} <span class="">{{ page.installs }}</span></div>
<div class="d-inline mr-3 tooltipped tooltipped-s" aria-label="{{ page.installations }} installations">{% octicon cloud-download width:14 class:"v-align-middle" %} <span class="">{{ page.installations }}</span></div>
<div class="d-inline mr-3 tooltipped tooltipped-s" aria-label="{{ page.stars }} stars">{% octicon star heigh:16 class:"v-align-middle" %} <span class="">{{ page.stars }}</span></div>
</div>
</div>

View File

@@ -49,7 +49,7 @@ layout: default
<p class="text-gray lh-condensed px-3 pb-3">{{ app.description }}</p>
<div class="text-gray-light pl-3 pr-2 py-2 bg-gray-light border-top" style="margin-top: auto;">
<div class="d-flex flex-row">
<div class="col-3 tooltipped tooltipped-s" aria-label="{{ app.installs }} installations">{% octicon cloud-download width:14 class:"v-align-middle" %} <span class="">{{ app.installs }}</span></div>
<div class="col-3 tooltipped tooltipped-s" aria-label="{{ app.installations }} installations">{% octicon cloud-download width:14 class:"v-align-middle" %} <span class="">{{ app.installations }}</span></div>
<div class="col-3 tooltipped tooltipped-s" aria-label="{{ app.stars }} stars">{% octicon star heigh:16 class:"v-align-middle" %} <span class="">{{ app.stars }}</span></div>
<div class="col-6 text-right">
<img class="avatar tooltipped tooltipped-s" aria-label="Made by {{ app.author }}" height="24" src="https://github.com/{{ app.author }}.png">

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env ruby
# Sync star counts from GitHub
require 'open-uri'
require "octokit"
client = Octokit::Client.new(:access_token => ENV["GITHUB_TOKEN"])
@@ -10,9 +12,18 @@ site = Jekyll::Site.new(config)
site.read
site.collections["apps"].docs.each do |app|
puts "Syncing #{app['repository']}"
repo = client.repository(app['repository'])
content = File.read(app.path)
content.sub!(/^stars: \d+$/, "stars: #{repo[:stargazers_count]}")
if app['host']
stats = JSON.parse(URI(app['host'] + '/stats').open.read)
content.sub!(/^installations: \d+$/, "installations: #{stats['installations']}")
yaml = YAML.dump(stats['popular'].map { |org| org['login'] }).sub('---', '')
content.sub!(/^organizations:\n(- .*\n)*/, "organizations:#{yaml}")
end
File.write(app.path, content)
end