forked from sketchplugins/plugin-directory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats
executable file
·73 lines (61 loc) · 2.95 KB
/
stats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env ruby
require 'octokit'
require 'json'
GITHUB_AUTH_TOKEN = `git config com.bohemiancoding.qa.token`.strip
ISSUES_PER_PAGE = 2000
USERNAME = `git config github.user`.strip
client = Octokit::Client.new(:access_token => GITHUB_AUTH_TOKEN)
file = File.read('plugins.json')
json_data = JSON.parse(file)
total_plugin_count = json_data.size
plugin_count = 0
open('plugin-stats.md', 'w') { |f|
f.puts "# Plugin stats - #{Time.now}"
f.puts
f.puts "Total plugins: #{total_plugin_count}"
f.puts
}
open('plugin-stats.csv', 'w') { |f|
f.puts "Name,Last Pushed,Stars,Open Issues,URL"
}
json_data.each do |plugin|
plugin_name = plugin['name']
plugin_title = plugin['title'] || plugin_name
plugin_owner = plugin['owner']
plugin_author = plugin['author']
plugin_count += 1
puts "#{plugin_count} / #{total_plugin_count} : #{plugin_name}"
if plugin_name && plugin_owner
begin
repo_name = plugin_owner + '/' + plugin_name
repo = client.repo(repo_name)
updated_days_ago = ((Time.now - repo.pushed_at) / (60 * 60 * 24)).to_i
open('plugin-stats.md', 'a') { |f|
f.puts
f.puts "#{plugin_count}. [#{plugin_title}](https://github.com/#{repo_name})"
f.puts
f.puts " Last push: #{repo.pushed_at} (#{updated_days_ago} days ago)"
if updated_days_ago > 900
f.puts " FIXME: Remove this from directory"
end
f.puts " Stars: #{repo.stargazers_count}"
f.puts " Open issues: #{repo.open_issues_count}"
}
open('plugin-stats.csv', 'a') { |f|
f.puts "#{plugin_title.gsub(',','')},#{repo.pushed_at},#{repo.stargazers_count},#{repo.open_issues_count},https://github.com/#{repo_name}"
}
rescue
# puts "Plugin has no repo."
open('plugin-stats.md', 'a') { |f|
f.puts
f.puts "#{plugin_count}. #{repo_name}"
f.puts
f.puts " FIXME: #{repo_name} has no repo"
f.puts
}
end
end
# #<Set: {:id, :name, :full_name, :owner, :private, :html_url, :description, :fork, :url, :forks_url, :keys_url, :collaborators_url, :teams_url, :hooks_url, :issue_events_url, :events_url, :assignees_url, :branches_url, :tags_url, :blobs_url, :git_tags_url, :git_refs_url, :trees_url, :statuses_url, :languages_url, :stargazers_url, :contributors_url, :subscribers_url, :subscription_url, :commits_url, :git_commits_url, :comments_url, :issue_comment_url, :contents_url, :compare_url, :merges_url, :archive_url, :downloads_url, :issues_url, :pulls_url, :milestones_url, :notifications_url, :labels_url, :releases_url, :deployments_url, :created_at, :updated_at, :pushed_at, :git_url, :ssh_url, :clone_url, :svn_url, :homepage, :size, :stargazers_count, :watchers_count, :language, :has_issues, :has_downloads, :has_wiki, :has_pages, :forks_count, :mirror_url, :open_issues_count, :forks, :open_issues, :watchers, :default_branch, :permissions, :network_count, :subscribers_count}>
end
puts
puts "#{total_plugin_count} plugins"