Skip to content

Commit 12e4384

Browse files
authored
Merge pull request #9 from coderdojo-japan/improve-image-loading-by-caching
Improve image loading by caching
2 parents 919d177 + cbe416d commit 12e4384

File tree

215 files changed

+2517
-2517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+2517
-2517
lines changed

.github/workflows/scheduler_daily.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ jobs:
4646
run: |
4747
bundle exec ruby get_dojos_from_japan.rb
4848
49+
- name: ☯️ Cache Dojo logos in Japan
50+
run: |
51+
bundle exec ruby caching_images.rb
52+
4953
- name: 📍 Generate DojoMap from Earth/Japan data
5054
run: |
5155
bundle exec ruby upsert_dojos_geojson.rb
@@ -59,6 +63,7 @@ jobs:
5963
git add Gemfile.lock
6064
git add dojos_earth.json
6165
git add dojos_japan.json
66+
git add images/dojos
6267
git add dojos.geojson
6368
git commit -m '🤖 Upsert Earth/Japan data for DojoMap'
6469
git push origin main

caching_images.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env ruby
2+
require 'json'
3+
require 'open-uri'
4+
5+
# Caching images from coderdojo.jp to local filesystem
6+
dojos_japan = []
7+
File.open('dojos_japan.json') do |file|
8+
dojos_japan = JSON.load(file, nil, symbolize_names: true, create_additions: false)
9+
end
10+
11+
FILEPATH = 'images/dojos'
12+
filename = ''
13+
dojos_japan.each do |dojo|
14+
filename = dojo[:logo].split('/').last
15+
next(puts "Skipped: #{filename}") if File.exist? "#{FILEPATH}/#{filename}"
16+
17+
puts "Try downloading image: " + dojo[:logo]
18+
URI.open(dojo[:logo]) do |image|
19+
File.open("#{FILEPATH}/#{filename}", "wb") do |file|
20+
file.write(image.read)
21+
end
22+
end
23+
end
24+
puts "Finished caching images for DojoMap."
25+
puts

dojos.geojson

Lines changed: 2292 additions & 2322 deletions
Large diffs are not rendered by default.

dojos_earth.json

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -5762,30 +5762,6 @@
57625762
"day": null,
57635763
"id": "15ac617b-967b-4497-b1a8-5713a64cc28d"
57645764
},
5765-
{
5766-
"entity$": "-/cd/dojos",
5767-
"name": "Dublin @ Riot Games",
5768-
"geoPoint": {
5769-
"lat": 53.34638400000001,
5770-
"lon": -6.245101999999974
5771-
},
5772-
"country": {
5773-
"countryName": "Ireland",
5774-
"countryNumber": 372,
5775-
"continent": "EU",
5776-
"alpha2": "IE",
5777-
"alpha3": "IRL"
5778-
},
5779-
"stage": 2,
5780-
"urlSlug": "ie/dublin/dublin-riot-games",
5781-
"startTime": null,
5782-
"endTime": null,
5783-
"private": 0,
5784-
"frequency": "other",
5785-
"alternativeFrequency": "6pm - 7:30pm",
5786-
"day": null,
5787-
"id": "a6796f63-db6b-429b-b2bd-612e0f107c84"
5788-
},
57895765
{
57905766
"entity$": "-/cd/dojos",
57915767
"name": "Eccles @ Eccles Cong",
@@ -26225,30 +26201,6 @@
2622526201
"day": null,
2622626202
"id": "d02701b7-0956-44a4-b55c-540da010ac9e"
2622726203
},
26228-
{
26229-
"entity$": "-/cd/dojos",
26230-
"name": "Oughterard",
26231-
"geoPoint": {
26232-
"lat": 53.428969322725976,
26233-
"lon": -9.31917428970337
26234-
},
26235-
"country": {
26236-
"countryName": "Ireland",
26237-
"countryNumber": 372,
26238-
"continent": "EU",
26239-
"alpha2": "IE",
26240-
"alpha3": "IRL"
26241-
},
26242-
"stage": 1,
26243-
"urlSlug": "ie/oughterard/oughterard",
26244-
"startTime": "19:00:00",
26245-
"endTime": "20:30:00",
26246-
"private": 0,
26247-
"frequency": "1/w",
26248-
"alternativeFrequency": "Thursday 7-8:30 pm",
26249-
"day": 4,
26250-
"id": "d4d4eb4f-d873-4543-b26f-b28d575c422e"
26251-
},
2625226204
{
2625326205
"entity$": "-/cd/dojos",
2625426206
"name": "Midlothian Coding Collective @ Mayfield Library",
@@ -61442,27 +61394,6 @@
6144261394
"day": null,
6144361395
"id": "5c781534-ae56-4dd2-8049-c6057041073a"
6144461396
},
61445-
{
61446-
"entity$": "-/cd/dojos",
61447-
"name": "Dublin Docklands @ CHQ",
61448-
"geoPoint": {
61449-
"lat": 53.349321688468414,
61450-
"lon": -6.247529983520508
61451-
},
61452-
"country": {
61453-
"countryName": "Ireland",
61454-
"alpha2": "IE"
61455-
},
61456-
"stage": 0,
61457-
"urlSlug": "ie/dublin/dublin/dublin-docklands-chq",
61458-
"startTime": "18:00:00",
61459-
"endTime": "19:30:00",
61460-
"private": 0,
61461-
"frequency": "2/m",
61462-
"alternativeFrequency": "***Currently taking a break for the summer - back in September 2018!***",
61463-
"day": 2,
61464-
"id": "358784b6-79e2-4e43-80a4-792da79f5418"
61465-
},
6146661397
{
6146761398
"entity$": "-/cd/dojos",
6146861399
"name": "CoderDojo Göteborg",
@@ -71327,6 +71258,30 @@
7132771258
"day": 4,
7132871259
"id": "64c791d4-6e2d-4efc-a48a-dae788a2dda3"
7132971260
},
71261+
{
71262+
"entity$": "-/cd/dojos",
71263+
"name": "Oughterard",
71264+
"geoPoint": {
71265+
"lat": 53.4277424,
71266+
"lon": -9.3212233
71267+
},
71268+
"country": {
71269+
"countryName": "Ireland",
71270+
"countryNumber": 372,
71271+
"continent": "EU",
71272+
"alpha2": "IE",
71273+
"alpha3": "IRL"
71274+
},
71275+
"stage": 1,
71276+
"urlSlug": "ie/oughterard/oughterard",
71277+
"startTime": "19:30:00",
71278+
"endTime": "20:30:00",
71279+
"private": 0,
71280+
"frequency": "1/w",
71281+
"alternativeFrequency": "Thursday 7-8:30 pm",
71282+
"day": 2,
71283+
"id": "d4d4eb4f-d873-4543-b26f-b28d575c422e"
71284+
},
7133071285
{
7133171286
"entity$": "-/cd/dojos",
7133271287
"name": "Oldenburg@KtT",
@@ -72041,6 +71996,30 @@
7204171996
"day": 7,
7204271997
"id": "d44d8fee-db0c-4a30-bc81-62f156039138"
7204371998
},
71999+
{
72000+
"entity$": "-/cd/dojos",
72001+
"name": "York",
72002+
"geoPoint": {
72003+
"lat": 53.95371799999999,
72004+
"lon": -1.129296
72005+
},
72006+
"country": {
72007+
"countryName": "United Kingdom",
72008+
"continent": "EU",
72009+
"alpha2": "GB",
72010+
"alpha3": "GBR",
72011+
"countryNumber": "826"
72012+
},
72013+
"stage": 4,
72014+
"urlSlug": "gb/york/york-1",
72015+
"startTime": "00:00:00",
72016+
"endTime": "00:00:00",
72017+
"private": 0,
72018+
"frequency": "other",
72019+
"alternativeFrequency": "Every 2 months",
72020+
"day": 2,
72021+
"id": "af7e2387-b442-49db-8265-e4e6fd0b2bc9"
72022+
},
7204472023
{
7204572024
"entity$": "-/cd/dojos",
7204672025
"name": "Camberwell Library @ Codefamily",
@@ -75755,6 +75734,30 @@
7575575734
"day": 4,
7575675735
"id": "5bd92e2e-9d7c-4849-95aa-846100ffd802"
7575775736
},
75737+
{
75738+
"entity$": "-/cd/dojos",
75739+
"name": "Dublin @ Riot Games",
75740+
"geoPoint": {
75741+
"lat": 53.34638400000001,
75742+
"lon": -6.245101999999974
75743+
},
75744+
"country": {
75745+
"countryName": "Ireland",
75746+
"countryNumber": 372,
75747+
"continent": "EU",
75748+
"alpha2": "IE",
75749+
"alpha3": "IRL"
75750+
},
75751+
"stage": 4,
75752+
"urlSlug": "ie/dublin/dublin-riot-games",
75753+
"startTime": "00:00:00",
75754+
"endTime": "00:00:00",
75755+
"private": 1,
75756+
"frequency": "other",
75757+
"alternativeFrequency": "CLOSED",
75758+
"day": null,
75759+
"id": "a6796f63-db6b-429b-b2bd-612e0f107c84"
75760+
},
7575875761
{
7575975762
"entity$": "-/cd/dojos",
7576075763
"name": "Rio Rancho@Loma Colorado",
@@ -78347,6 +78350,27 @@
7834778350
"day": 6,
7834878351
"id": "55ed08ee-d405-4886-95d7-6c072ab28a2a"
7834978352
},
78353+
{
78354+
"entity$": "-/cd/dojos",
78355+
"name": "Dublin Docklands @ CHQ",
78356+
"geoPoint": {
78357+
"lat": 53.349321688468414,
78358+
"lon": -6.247529983520508
78359+
},
78360+
"country": {
78361+
"countryName": "Ireland",
78362+
"alpha2": "IE"
78363+
},
78364+
"stage": 0,
78365+
"urlSlug": "ie/dublin/dublin/dublin-docklands-chq",
78366+
"startTime": "18:00:00",
78367+
"endTime": "19:30:00",
78368+
"private": 0,
78369+
"frequency": "2/m",
78370+
"alternativeFrequency": "***Currently taking a break for the summer - back in September 2018!***",
78371+
"day": 2,
78372+
"id": "358784b6-79e2-4e43-80a4-792da79f5418"
78373+
},
7835078374
{
7835178375
"entity$": "-/cd/dojos",
7835278376
"name": "Alsace @Bischheim",
@@ -89156,30 +89180,6 @@
8915689180
"day": 7,
8915789181
"id": "d9a2266b-d2c3-4541-9ff2-0a665a76be00"
8915889182
},
89159-
{
89160-
"entity$": "-/cd/dojos",
89161-
"name": "York",
89162-
"geoPoint": {
89163-
"lat": 53.95371799999999,
89164-
"lon": -1.129296
89165-
},
89166-
"country": {
89167-
"countryName": "United Kingdom",
89168-
"continent": "EU",
89169-
"alpha2": "GB",
89170-
"alpha3": "GBR",
89171-
"countryNumber": "826"
89172-
},
89173-
"stage": 1,
89174-
"urlSlug": "gb/york/york-1",
89175-
"startTime": "00:00:00",
89176-
"endTime": "00:00:00",
89177-
"private": 0,
89178-
"frequency": "other",
89179-
"alternativeFrequency": "Every 2 months",
89180-
"day": 2,
89181-
"id": "af7e2387-b442-49db-8265-e4e6fd0b2bc9"
89182-
},
8918389183
{
8918489184
"entity$": "-/cd/dojos",
8918589185
"name": "Kasuga@春日市ふれあい文化センター",

0 commit comments

Comments
 (0)