-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Obtain some of the facts metadata from the data files information
- Loading branch information
1 parent
2f7fbd9
commit 79046e6
Showing
8 changed files
with
396 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
- ac | ||
- ad | ||
- ae | ||
- af | ||
- ag | ||
- ai | ||
- al | ||
- am | ||
- ao | ||
- aq | ||
- ar | ||
- as | ||
- at | ||
- au | ||
- aw | ||
- ax | ||
- az | ||
- ba | ||
- bb | ||
- bd | ||
- be | ||
- bf | ||
- bg | ||
- bh | ||
- bi | ||
- bj | ||
- bm | ||
- bn | ||
- bo | ||
- bq | ||
- br | ||
- bs | ||
- bt | ||
- bw | ||
- by | ||
- bz | ||
- ca | ||
- cc | ||
- cd | ||
- cf | ||
- cg | ||
- ch | ||
- ci | ||
- ck | ||
- cl | ||
- cm | ||
- cn | ||
- co | ||
- cr | ||
- cu | ||
- cv | ||
- cw | ||
- cx | ||
- cy | ||
- cz | ||
- de | ||
- dj | ||
- dk | ||
- dm | ||
- do | ||
- dz | ||
- ec | ||
- ee | ||
- eg | ||
- eh | ||
- er | ||
- es | ||
- et | ||
- eu | ||
- fi | ||
- fj | ||
- fk | ||
- fm | ||
- fo | ||
- fr | ||
- ga | ||
- gd | ||
- ge | ||
- gf | ||
- gg | ||
- gh | ||
- gi | ||
- gl | ||
- gm | ||
- gn | ||
- gp | ||
- gq | ||
- gr | ||
- gs | ||
- gt | ||
- gu | ||
- gw | ||
- gy | ||
- hk | ||
- hm | ||
- hn | ||
- hr | ||
- ht | ||
- hu | ||
- id | ||
- ie | ||
- il | ||
- im | ||
- in | ||
- io | ||
- iq | ||
- ir | ||
- is | ||
- it | ||
- je | ||
- jm | ||
- jo | ||
- jp | ||
- ke | ||
- kg | ||
- kh | ||
- ki | ||
- km | ||
- kn | ||
- kp | ||
- kr | ||
- kw | ||
- ky | ||
- kz | ||
- la | ||
- lb | ||
- lc | ||
- li | ||
- lk | ||
- lr | ||
- ls | ||
- lt | ||
- lu | ||
- lv | ||
- ly | ||
- ma | ||
- mc | ||
- md | ||
- me | ||
- mg | ||
- mh | ||
- mk | ||
- ml | ||
- mm | ||
- mn | ||
- mo | ||
- mp | ||
- mq | ||
- mr | ||
- ms | ||
- mt | ||
- mu | ||
- mv | ||
- mw | ||
- mx | ||
- my | ||
- mz | ||
- na | ||
- nc | ||
- ne | ||
- nf | ||
- ng | ||
- ni | ||
- nl | ||
- no | ||
- np | ||
- nr | ||
- nu | ||
- nz | ||
- om | ||
- pa | ||
- pe | ||
- pf | ||
- pg | ||
- ph | ||
- pk | ||
- pl | ||
- pm | ||
- pn | ||
- pr | ||
- ps | ||
- pt | ||
- pw | ||
- py | ||
- qa | ||
- re | ||
- ro | ||
- rs | ||
- ru | ||
- rw | ||
- sa | ||
- sb | ||
- sc | ||
- sd | ||
- se | ||
- sg | ||
- sh | ||
- si | ||
- sk | ||
- sl | ||
- sm | ||
- sn | ||
- so | ||
- sr | ||
- ss | ||
- st | ||
- su | ||
- sv | ||
- sx | ||
- sy | ||
- sz | ||
- tc | ||
- td | ||
- tf | ||
- tg | ||
- th | ||
- tj | ||
- tk | ||
- tl | ||
- tm | ||
- tn | ||
- to | ||
- tr | ||
- tt | ||
- tv | ||
- tw | ||
- tz | ||
- ua | ||
- ug | ||
- uk | ||
- us | ||
- uy | ||
- uz | ||
- va | ||
- vc | ||
- ve | ||
- vg | ||
- vi | ||
- vn | ||
- vu | ||
- wf | ||
- ws | ||
- ye | ||
- yt | ||
- za | ||
- zm | ||
- zw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
- value: 390 | ||
text: f1 | ||
text: instances | ||
- value: 30 | ||
text: f2 | ||
text: countries | ||
- value: 240 | ||
text: f3 | ||
text: institutions | ||
- value: 150 | ||
text: f4 | ||
text: organizations | ||
- value: "925.152" | ||
text: f5 | ||
text: participants | ||
- value: 427 | ||
text: f6 | ||
text: processes | ||
- value: "100.129" | ||
text: f7 | ||
text: proposals | ||
- value: "120.554" | ||
text: f8 | ||
text: comments | ||
- value: "11.215" | ||
text: f9 | ||
text: meetings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
|
||
require "addressable/uri" | ||
|
||
module FactsHelpers | ||
# Get the statistic for this fact type | ||
# If the fact type is not supported, then return the hard-coded figure given as a parameter | ||
# | ||
# @param data_type [String] - The name of the data type. For instance "instances" | ||
# @param fallback [Integer|String] - The number with the hard-coded value in case this type isn't supported | ||
# @param data [Middleman::CoreExtensions::Data::DataStore] - The data object from Middleman, to gather some of the information | ||
def get_statistic_for_fact(data_type, fallback, data) | ||
case data_type | ||
when "instances" | ||
data.installations.count | ||
when "organizations" | ||
data.installations.select {|name, installation| installation["type"] == "org" }.count | ||
when "institutions" | ||
data.installations.select {|name, installation| ["region", "city"].include? installation["type"] }.count | ||
when "countries" | ||
get_countries_from(data) | ||
else | ||
fallback | ||
end | ||
end | ||
|
||
private | ||
|
||
def get_countries_from(data) | ||
ctlds = data.installations | ||
.map {|name, installation| installation["url"] } | ||
.map { |url| url.gsub(%r{https://web.archive.org/web/\d*/}, "") } | ||
.map { |url| Addressable::URI.parse(url).tld } | ||
.map { |url| url.split(".")[-1] } # Seems like we're getting some garbage, like "milano.it", so this worksaround it | ||
.uniq | ||
|
||
counter = 0 | ||
ctlds.each do |ctld| | ||
counter+=1 if data.countries.include?(ctld) | ||
end | ||
|
||
counter | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.