GFDRR / open-risk-data-dashboard

Repository for the Open Data for Resilience Index, a website to track and improve the state of Open Data for Resilience worldwide.
https://index.opendri.org
GNU Lesser General Public License v3.0
23 stars 8 forks source link

Filter countries by region or specific clusters #244

Closed pzwsk closed 5 years ago

pzwsk commented 6 years ago

In https://index.opendri.org/countries.html add a filter to show only countries belonging to the group selected.

To be discussed: should we handle this both BE and FE side, with in the db a specific column for group (one country can have belong to more than one group) or one group per column with a boolean for each country.

What do you think @nastasi-oq ?

Here is the first list of clusters and regions:

nastasi-oq commented 6 years ago

Specific columns for groups don't scale very well. In my opinion we can use a many-to-many relation between the current Country table and a new Cluster table. Another interesting option could be a many-to-many relation between items of the same table (a generalization of the current Country table) adding a boolean field to distinguish between a cluster item and a country item. We need to evaluate pro and cons of both and then decide.

pzwsk commented 6 years ago

Hi @nastasi-oq how do you want me to provide the list of countries per group?

Would Country_Group_Name + list of WB_Code be ok?

nastasi-oq commented 6 years ago

Would Country_Group_Name + list of WB_Code be ok? LGTM A note: if you also want to use (or reuse a previous defined) coding schema for these groups you can also add it (like an arbitrary 3 char code to use a key).

pzwsk commented 6 years ago

Thanks,

as per your suggestion, I found that WB is actually using 2 characters (apha or digit) codes for some of the country groups (not for all). They even have a code for World which is 1W.

I suggest we use a "extended" version with our own codes for country groups that do not belong to this list.

So, please find below the updated list of countries (one change for World WB code), as well as list of Country Group.

Let me know if ok

Country_List.csv https://www.dropbox.com/s/4p2modfuv4euzro/Country_List.csv?dl=0

Country_Group.csv (Names of Country Group + WB Codes) https://www.dropbox.com/s/ns8c7ygwc7yum7n/Country_Group.csv?dl=0

Country_Group_Details (Name of Country Group + list of countries WB code) https://www.dropbox.com/s/1ef5nob61b5nigo/Country_Group_Details.csv?dl=0

pzwsk commented 6 years ago

Also, once updated, could you put those csv files in the back end folder and remove lists that are unused? Thanks!

CIMAManuel commented 5 years ago

A observation for client side development. In client side the list of country group can be set in two way:

  1. A static list insert manually in a select tag
  2. A dinamyc list with API call (API returns a list of available group, ex: code, description).

For me the best way is the second (2) for consistency between server and client. What about this? @pzwsk @nastasi-oq @oncletom

pzwsk commented 5 years ago

I agree,

also, we should then document somewhere how country list and country groups are implemented and keep flat CSV files in backend repository as original sources.

On Thu, Oct 25, 2018 at 10:26 AM CIMAManuel notifications@github.com wrote:

A observation for client side development. In client side the list of country group can be set in two way:

  1. A static list insert manually in a select tag
  2. A dinamyc list with API call (API returns a list of available group, ex: code, description).

For me the best way is the second (2) for consistency between server and client. What about this? @pzwsk https://github.com/pzwsk @nastasi-oq https://github.com/nastasi-oq @oncletom https://github.com/oncletom

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GFDRR/open-risk-data-dashboard/issues/244#issuecomment-432960460, or mute the thread https://github.com/notifications/unsubscribe-auth/ACRKx5KEk1nzraAdc9XiP1uRxNeDujYFks5uoXXEgaJpZM4XX3zy .

pzwsk commented 5 years ago

As discussed, moved to FE iteration #4

nastasi-oq commented 5 years ago

List of country groups with their associated countries from the CSV file, just for another visual check:

https://gist.github.com/nastasi-oq/093497115a279c77b568dba99bb9d1df

pzwsk commented 5 years ago

Yes I confirm, thank

On Fri, Nov 16, 2018 at 11:37 AM Matteo Nastasi notifications@github.com wrote:

List of country groups with their associated countries from the CSV file, just for another visual check:

Pacific Islands FJ: Fiji FM: Micronesia, Federated States of KI: Kiribati MH: Marshall Islands PW: Palau SB: Solomon Islands TO: Tonga VU: Vanuatu WS: Samoa

Small Island Developing States AG: Antigua and Barbuda BS: Bahamas, The BH: Bahrain BB: Barbados BZ: Belize CV: Cabo Verde KM: Comoros CU: Cuba DM: Dominica DO: Dominican Republic FJ: Fiji GD: Grenada GW: Guinea-Bissau GY: Guyana HT: Haiti JM: Jamaica KI: Kiribati MV: Maldives MH: Marshall Islands MU: Mauritius FM: Micronesia, Federated States of NR: Nauru PW: Palau PG: Papua New Guinea WS: Samoa ST: Sao Tome and Principe SC: Seychelles SG: Singapore SB: Solomon Islands KN: St. Kitts and Nevis LC: St. Lucia VC: St. Vincent and the Grenadines SR: Suriname TP: Timor-Leste TO: Tonga TT: Trinidad and Tobago TV: Tuvalu VU: Vanuatu

East Asia and Pacific CN: China FJ: Fiji FM: Micronesia, Federated States of ID: Indonesia KH: Cambodia KI: Kiribati KR: Korea, Republic of LA: Lao People's Democratic Republic MH: Marshall Islands MM: Myanmar MN: Mongolia MY: Malaysia PG: Papua New Guinea PH: Philippines PW: Palau SB: Solomon Islands TH: Thailand TO: Tonga VN: Vietnam VU: Vanuatu WS: Samoa

Europe and Central Asia AL: Albania AM: Armenia AZ: Azerbaijan BA: Bosnia and Herzegovina BG: Bulgaria BY: Belarus CY: Cyprus CZ: Czech Republic EE: Estonia GE: Georgia HR: Croatia HU: Hungary KG: Kyrgyz Republic KZ: Kazakhstan LT: Lithuania LV: Latvia MD: Moldova MK: Macedonia, former Yugoslav Republic of PL: Poland PT: Portugal RO: Romania RU: Russian Federation SI: Slovenia SK: Slovak Republic TJ: Tajikistan TM: Turkmenistan TR: Turkey UA: Ukraine UZ: Uzbekistan YF: Serbia Latin America and The Carribean AG: Antigua and Barbuda AR: Argentina BB: Barbados BO: Bolivia BR: Brazil BS: Bahamas, The BZ: Belize CL: Chile CO: Colombia CR: Costa Rica DM: Dominica DO: Dominican Republic EC: Ecuador GD: Grenada GT: Guatemala GY: Guyana HN: Honduras HT: Haiti JM: Jamaica KN: St. Kitts and Nevis LC: St. Lucia MX: Mexico NI: Nicaragua PA: Panama PE: Peru PY: Paraguay SR: Suriname SV: El Salvador TT: Trinidad and Tobago UY: Uruguay VC: St. Vincent and the Grenadines VE: Venezuela Middle East and North Africa AE: United Arab Emirates BH: Bahrain DZ: Algeria EG: Egypt, Arab Republic of GZ: West Bank and Gaza IQ: Iraq IR: Iran, Islamic Republic of JO: Jordan KW: Kuwait LB: Lebanon LY: Libya MA: Morocco MT: Malta OM: Oman QA: Qatar RY: Yemen, Republic of SA: Saudi Arabia SY: Syrian Arab Republic TN: Tunisia South Asia AF: Afghanistan BD: Bangladesh BT: Bhutan IN: India LK: Sri Lanka MV: Maldives NP: Nepal PK: Pakistan Sub-Saharan Africa AO: Angola BF: Burkina Faso BI: Burundi BJ: Benin BW: Botswana CF: Central African Republic CG: Congo, Republic of CI: Cote d'Ivoire CM: Cameroon CV: Cabo Verde DJ: Djibouti ER: Eritrea ET: Ethiopia GA: Gabon GH: Ghana GM: Gambia, The GN: Guinea GQ: Equatorial Guinea GW: Guinea-Bissau KE: Kenya KM: Comoros LR: Liberia LS: Lesotho MG: Madagascar ML: Mali MR: Mauritania MU: Mauritius MW: Malawi MZ: Mozambique NA: Namibia NE: Niger NG: Nigeria RW: Rwanda SC: Seychelles SD: Sudan SL: Sierra Leone SN: Senegal SO: Somalia SS: South Sudan ST: Sao Tome and Principe SZ: Eswatini TD: Chad TG: Togo TZ: Tanzania UG: Uganda ZA: South Africa ZM: Zambia ZR: Congo, Democratic Republic of ZW: Zimbabwe Europe AD: Andorra AL: Albania AT: Austria BA: Bosnia and Herzegovina BE: Belgium BG: Bulgaria BY: Belarus CH: Switzerland CZ: Czech Republic DE: Germany DK: Denmark EE: Estonia ES: Spain FI: Finland FR: France GB: United Kingdom GG: Guernsey, C.I. GI: Gibraltar GR: Greece HR: Croatia HU: Hungary IE: Ireland IM: Isle of Man IS: Iceland IT: Italy JE: Jersey, C.I. LI: Liechtenstein LT: Lithuania LU: Luxembourg LV: Latvia MC: Monaco MD: Moldova MK: Macedonia, former Yugoslav Republic of MT: Malta NL: Netherlands NO: Norway PL: Poland PT: Portugal RO: Romania RU: Russian Federation SE: Sweden SI: Slovenia SK: Slovak Republic TR: Turkey UA: Ukraine YF: Serbia

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GFDRR/open-risk-data-dashboard/issues/244#issuecomment-439353238, or mute the thread https://github.com/notifications/unsubscribe-auth/ACRKxyhlrQ1bdcgsNYWGMz8Q-paUgKVuks5uvpWDgaJpZM4XX3zy .

nastasi-oq commented 5 years ago

API UPDATES

New countries list

http://www.example.com/api/country/

country

How to retrieve country_groups list

http://www.example.com/api/country_group/

country_group

How to filter countries by country_group

www.example.com/api/country/?country_group=1E

country_filtered

How to filter country_scoring by country_group

www.example.com/api/country_scoring/?country_group=1E

country_scoring_filtered


REFERENCE BRANCH: country_groups2 (@CIMAManuel NOT country_groups)

Already active on our new BE+FE experimental integration facility

nastasi-oq commented 5 years ago

From Backend point of view the issue is completed, the version now is 1.0.0 because the back-compatibility is broken on /country/ view. When also Frontend side will be updated we can open a consistent PR. @pzwsk @oncletom @CIMAManuel

pzwsk commented 5 years ago

Thanks,

one minor thing: API response for country code says iso2 but this not iso code but wb_ code or wb_id Could we change that? This may create confusion in the future.

Best

On ven. 16 nov. 2018 à 5:08 PM Matteo Nastasi notifications@github.com wrote:

From Backend point of view the issue is completed, the version now is 1.0.0 because the backc-compatibility is broken on /country/ view. When also Frontend side will be updated we can open a consistent PR. @pzwsk https://github.com/pzwsk @oncletom https://github.com/oncletom @CIMAManuel https://github.com/CIMAManuel

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GFDRR/open-risk-data-dashboard/issues/244#issuecomment-439441754, or mute the thread https://github.com/notifications/unsubscribe-auth/ACRKx1ZOz5je7HfoPLOLRuTbjwmG-Y6Uks5uvuL1gaJpZM4XX3zy .

-- Pierre Chrzanowski | Open Data Expert Skype: pierre.chrzanowski | Twitter: @pzwsk

thom4parisot commented 5 years ago

@nastasi-oq small question: is there a way to know in which group(s) a country is from the /api/country/ endpoint?

So far, my understanding is the API has to be queried to get to know this answer.

nastasi-oq commented 5 years ago

@nastasi-oq small question: is there a way to know in which group(s) a country is from the /api/country/ endpoint?

@oncletom
No, I explicitly asked about this option and the answer is that it isn't an exposed information.

nastasi-oq commented 5 years ago

@pzwsk

one minor thing: API response for country code says iso2 but this not iso code but wb_ code or wb_id Could we change that? This may create confusion in the future.

I agree and thinking about this not backward compatible change I also decided to investigate the possibility to move the new wb_id as primary key of Country model, making more readable any relation in the database, working on it since Monday I'm analyzing result of a refactored migration and I plan to open a new PR that MUST be merged before Country Group PR.

pzwsk commented 5 years ago

Ok sounds good, thanks

On Tue, Nov 20, 2018 at 11:06 AM Matteo Nastasi notifications@github.com wrote:

@pzwsk https://github.com/pzwsk

one minor thing: API response for country code says iso2 but this not iso code but wb_ code or wb_id Could we change that? This may create confusion in the future.

I agree and thinking about this not backward compatible change I also decided to investigate the possibility to move the new wb_id as primary key of Country model, making more readable any relation in the database, working on it since Monday I'm analyzing result of a refactored migration and I plan to open a new PR that MUST be merged before Country Group PR.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GFDRR/open-risk-data-dashboard/issues/244#issuecomment-440216050, or mute the thread https://github.com/notifications/unsubscribe-auth/ACRKx_3pOE1aOmrUnFX18_Vlz5GLQux8ks5uw9QQgaJpZM4XX3zy .

nastasi-oq commented 5 years ago

Implemented in #328