Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📊 Automate to update profile upon dojo stats #19

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions _data/stats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
active_dojos: 180
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ <h3 class="headline rich_font">DecaDojo とは?</h3>

<h3 class="headline rich_font" style='margin-top: 70px;'>CoderDojo とは?</h3>
<div class="desc">
<p>CoderDojo は7〜17歳を対象とした非営利のプログラミング道場です。2011年にアイルランドで始まり、世界では100カ国・2,000の道場、<a href='https://coderdojo.jp/'>日本には180以上の道場</a>があります。</p>
<p>CoderDojo は7〜17歳を対象とした非営利のプログラミング道場です。2011年にアイルランドで始まり、世界では100カ国・2,000の道場、<a href='https://coderdojo.jp/'>日本には{{ site.data.stats['active_dojos'] }}以上の道場</a>があります。</p>
</div>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions update_profile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby

require 'net/http'
require 'json'
require 'yaml'

BASE_URL = 'https://coderdojo.jp'
DOJO_STATS = JSON.parse Net::HTTP.get(URI.parse "#{BASE_URL}/stats.json"), symbolize_names: true
STATS_PATH = '_data/stats.yml'

stats = YAML.load_file(STATS_PATH)
stats['active_dojos'] = DOJO_STATS[:active_dojos]
YAML.dump stats, File.open(STATS_PATH, 'w')