Choose which facilities to import from Vancouver City's Open Data API.
+ + <%= form_with url: import_facilities_admin_tools_path, method: :post, class: "form", id: "import-form" do |form| %> +diff --git a/Gemfile b/Gemfile index 9faed820..902f6917 100644 --- a/Gemfile +++ b/Gemfile @@ -119,3 +119,6 @@ gem "cssbundling-rails", "~> 1.4" # Aborts requests that are taking too long. # Set the timeout by setting the RACK_TIMEOUT_SERVICE_TIMEOUT env var # gem "rack-timeout" + +# Http client for making API requests +gem "faraday", "~> 2.13.1" diff --git a/Gemfile.lock b/Gemfile.lock index 033da032..db9e66bd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -134,6 +134,12 @@ GEM railties (>= 5.0.0) faker (3.4.2) i18n (>= 1.8.11, < 2) + faraday (2.13.1) + faraday-net_http (>= 2.0, < 3.5) + json + logger + faraday-net_http (3.4.1) + net-http (>= 0.5.0) ffi (1.16.3) geo_coord (0.2.0) geocoder (1.8.2) @@ -163,6 +169,7 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) + logger (1.7.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -178,6 +185,8 @@ GEM mini_mime (1.1.5) minitest (5.25.1) msgpack (1.7.2) + net-http (0.6.0) + uri net-imap (0.4.10) date net-protocol @@ -349,6 +358,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) + uri (1.0.3) view_component (3.11.0) activesupport (>= 5.2.0, < 8.0) concurrent-ruby (~> 1.0) @@ -387,6 +397,7 @@ DEPENDENCIES dotenv-rails factory_bot_rails (~> 6.4.3) faker (~> 3.4.2) + faraday (~> 2.13.1) geo_coord geocoder (~> 1.8) haversine! diff --git a/app/components/layout/header_component/header_component.html.erb b/app/components/layout/header_component/header_component.html.erb index 21996d34..93efc94e 100644 --- a/app/components/layout/header_component/header_component.html.erb +++ b/app/components/layout/header_component/header_component.html.erb @@ -49,6 +49,12 @@
- <%= form_with url: admin_facilities_path, method: :get, data: { controller: "auto-submit" } do |form| %> + <%= form_with url: admin_facilities_path, method: :get, data: { controller: "auto-submit" } do |form| %>Choose which facilities to import from Vancouver City's Open Data API.
+ + <%= form_with url: import_facilities_admin_tools_path, method: :post, class: "form", id: "import-form" do |form| %> +This dataset displays level 0 world administrative boundaries. It contains countries as well as non-sovereign territories (like, for instance, French overseas).
", + "modified_updates_on_metadata_change": false, + "shared_catalog": null, + "source_domain": null, + "attributions": null, + "geographic_area_mode": null, + "geographic_reference_auto": true, + "geographic_area": null, + "publisher": "World Food Programme (UN agency)", + "language": "en", + "license": "Open Government Licence v3.0", + "source_dataset": null, + "metadata_languages": [ + "en" + ], + "oauth_scope": null, + "federated": true, + "license_url": "http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" + } + }, + "features": [ + "analyze", + "geo" + ] + }, + { + "dataset_id": "geonames-all-cities-with-a-population-1000", + "dataset_uid": "da_5m8ykr", + "attachments": [ + { + "mimetype": "application/zip", + "url": "odsfile://cities1000.zip", + "id": "cities1000_zip", + "title": "cities1000.zip" + } + ], + "has_records": true, + "data_visible": true, + "fields": [ + { + "description": null, + "label": "Geoname ID", + "type": "text", + "name": "geoname_id", + "annotations": { + "facetsort": [ + "-count" + ], + "id": [] + } + }, + { + "description": null, + "label": "Name", + "type": "text", + "name": "name", + "annotations": { + "sortable": [] + } + }, + { + "description": null, + "label": "ASCII Name", + "type": "text", + "name": "ascii_name", + "annotations": {} + }, + { + "description": null, + "label": "Alternate Names", + "type": "text", + "name": "alternate_names", + "annotations": { + "multivalued": [ + "," + ] + } + }, + { + "description": "see http://www.geonames.org/export/codes.html", + "label": "Feature Class", + "type": "text", + "name": "feature_class", + "annotations": {} + }, + { + "description": "see http://www.geonames.org/export/codes.html", + "label": "Feature Code", + "type": "text", + "name": "feature_code", + "annotations": {} + }, + { + "description": null, + "label": "Country Code", + "type": "text", + "name": "country_code", + "annotations": {} + }, + { + "description": null, + "label": "Country name EN", + "type": "text", + "name": "cou_name_en", + "annotations": { + "facet": [], + "facetsort": [ + "alphanum" + ], + "disjunctive": [] + } + }, + { + "description": null, + "label": "Country Code 2", + "type": "text", + "name": "country_code_2", + "annotations": {} + }, + { + "description": null, + "label": "Admin1 Code", + "type": "text", + "name": "admin1_code", + "annotations": {} + }, + { + "description": null, + "label": "Admin2 Code", + "type": "text", + "name": "admin2_code", + "annotations": { + "facetsort": [ + "-count" + ] + } + }, + { + "description": null, + "label": "Admin3 Code", + "type": "text", + "name": "admin3_code", + "annotations": {} + }, + { + "description": null, + "label": "Admin4 Code", + "type": "text", + "name": "admin4_code", + "annotations": {} + }, + { + "description": null, + "label": "Population", + "type": "int", + "name": "population", + "annotations": {} + }, + { + "description": null, + "label": "Elevation", + "type": "text", + "name": "elevation", + "annotations": {} + }, + { + "description": null, + "label": "DIgital Elevation Model", + "type": "int", + "name": "dem", + "annotations": {} + }, + { + "description": null, + "label": "Timezone", + "type": "text", + "name": "timezone", + "annotations": { + "facet": [], + "hierarchical": [ + "/" + ] + } + }, + { + "description": null, + "label": "Modification date", + "type": "date", + "name": "modification_date", + "annotations": {} + }, + { + "description": null, + "label": "LABEL EN", + "type": "text", + "name": "label_en", + "annotations": {} + }, + { + "description": null, + "label": "Coordinates", + "type": "geo_point_2d", + "name": "coordinates", + "annotations": { + "facetsort": [ + "-count" + ] + } + } + ], + "metas": { + "default": { + "records_count": 137609, + "modified": "2021-06-23T14:37:45+00:00", + "source_domain_address": null, + "references": null, + "keyword": null, + "source_domain_title": null, + "geographic_reference": [ + "world" + ], + "timezone": null, + "title": "Geonames - All Cities with a population > 1000", + "parent_domain": null, + "theme": null, + "modified_updates_on_data_change": false, + "metadata_processed": "2021-06-23T14:49:23.198000+00:00", + "data_processed": "2021-06-23T14:49:23+00:00", + "territory": [ + "World" + ], + "description": null, + "modified_updates_on_metadata_change": false, + "shared_catalog": null, + "source_domain": null, + "attributions": null, + "geographic_area_mode": null, + "geographic_reference_auto": true, + "geographic_area": null, + "publisher": null, + "language": "en", + "license": null, + "source_dataset": null, + "metadata_languages": [ + "en" + ], + "oauth_scope": null, + "federated": false, + "license_url": null + } + }, + "features": [ + "geo", + "analyze", + "timeserie" + ] + } + ] + } + }, + "catalog_facets": { + "value": { + "links": [], + "facets": [ + { + "name": "publisher", + "facets": [ + { + "count": 2, + "state": "displayed", + "name": "Opendatasoft", + "value": "Opendatasoft" + }, + { + "count": 2, + "state": "displayed", + "name": "Opendatasoft - Data Team", + "value": "Opendatasoft - Data Team" + } + ] + }, + { + "name": "features", + "facets": [ + { + "count": 19, + "state": "displayed", + "name": "analyze", + "value": "analyze" + }, + { + "count": 13, + "state": "displayed", + "name": "timeserie", + "value": "timeserie" + } + ] + }, + { + "name": "language", + "facets": [ + { + "count": 17, + "state": "displayed", + "name": "en", + "value": "en" + }, + { + "count": 4, + "state": "displayed", + "name": "fr", + "value": "fr" + } + ] + } + ] + } + }, + "records": { + "value": { + "total_count": 137611, + "links": [], + "records": [ + { + "links": [], + "record": { + "id": "53d4524dcb82c676bacd467cd5ace953f2e0389c", + "timestamp": "2021-06-22T08:02:59.954Z", + "size": 194, + "fields": { + "admin1_code": "27", + "elevation": null, + "name": "Saint-Leu", + "modification_date": "2019-03-26", + "alternate_names": [ + "Saint-Leu" + ], + "feature_class": "P", + "admin3_code": "711", + "cou_name_en": "France", + "coordinates": { + "lat": 46.7306, + "lon": 4.50083 + }, + "country_code_2": null, + "geoname_id": "2978771", + "feature_code": "PPL", + "label_en": "France", + "dem": 366, + "country_code": "FR", + "ascii_name": "Saint-Leu", + "timezone": "Europe/Paris", + "admin2_code": "71", + "admin4_code": "71436", + "population": 29278 + } + } + }, + { + "links": [], + "record": { + "id": "d5251445f329dc74cc5c5e30c95378eb9807a019", + "timestamp": "2021-06-22T08:02:59.954Z", + "size": 310, + "fields": { + "admin1_code": "32", + "elevation": null, + "name": "Saint-Léger-lès-Domart", + "modification_date": "2016-02-18", + "alternate_names": [ + "Saint-Leger", + "Saint-Leger-les-Domart", + "Saint-Léger", + "Saint-Léger-lès-Domart" + ], + "feature_class": "P", + "admin3_code": "802", + "cou_name_en": "France", + "coordinates": { + "lat": 50.05208, + "lon": 2.14067 + }, + "country_code_2": null, + "geoname_id": "2978817", + "feature_code": "PPL", + "label_en": "France", + "dem": 31, + "country_code": "FR", + "ascii_name": "Saint-Leger-les-Domart", + "timezone": "Europe/Paris", + "admin2_code": "80", + "admin4_code": "80706", + "population": 1781 + } + } + } + ] + } + }, + "group_by_country-v2.1": { + "value": { + "results": [ + { + "count": 16729, + "cou_name_en": "United States" + }, + { + "count": 9945, + "cou_name_en": "Italy" + }, + { + "count": 8981, + "cou_name_en": "Mexico" + } + ] + } + }, + "dataset-v2.1": { + "value": { + "dataset_id": "geonames-all-cities-with-a-population-1000", + "dataset_uid": "da_s2n5ed", + "attachments": [], + "has_records": true, + "data_visible": true, + "fields": [ + { + "description": null, + "label": "Geoname ID", + "type": "text", + "name": "geoname_id", + "annotations": { + "facetsort": [ + "-count" + ], + "id": [] + } + }, + { + "description": null, + "label": "Name", + "type": "text", + "name": "name", + "annotations": { + "sortable": [] + } + }, + { + "annotations": {}, + "description": null, + "type": "text", + "name": "ascii_name", + "label": "ASCII Name" + }, + { + "description": null, + "label": "Alternate Names", + "type": "text", + "name": "alternate_names", + "annotations": { + "multivalued": [ + "," + ] + } + }, + { + "annotations": {}, + "label": "Feature Class", + "type": "text", + "name": "feature_class", + "description": "see http://www.geonames.org/export/codes.html" + }, + { + "annotations": {}, + "label": "Feature Code", + "type": "text", + "name": "feature_code", + "description": "see http://www.geonames.org/export/codes.html" + }, + { + "annotations": {}, + "description": null, + "type": "text", + "name": "country_code", + "label": "Country Code" + }, + { + "description": null, + "label": "Country name EN", + "type": "text", + "name": "cou_name_en", + "annotations": { + "facet": [], + "facetsort": [ + "alphanum" + ], + "disjunctive": [] + } + }, + { + "annotations": {}, + "description": null, + "type": "text", + "name": "country_code_2", + "label": "Country Code 2" + }, + { + "annotations": {}, + "description": null, + "type": "text", + "name": "admin1_code", + "label": "Admin1 Code" + }, + { + "description": null, + "label": "Admin2 Code", + "type": "text", + "name": "admin2_code", + "annotations": { + "facetsort": [ + "-count" + ] + } + }, + { + "annotations": {}, + "description": null, + "type": "text", + "name": "admin3_code", + "label": "Admin3 Code" + }, + { + "annotations": {}, + "description": null, + "type": "text", + "name": "admin4_code", + "label": "Admin4 Code" + }, + { + "annotations": {}, + "description": null, + "type": "int", + "name": "population", + "label": "Population" + }, + { + "annotations": {}, + "description": null, + "type": "text", + "name": "elevation", + "label": "Elevation" + }, + { + "annotations": {}, + "description": null, + "type": "int", + "name": "dem", + "label": "DIgital Elevation Model" + }, + { + "description": null, + "label": "Timezone", + "type": "text", + "name": "timezone", + "annotations": { + "facet": [], + "hierarchical": [ + "/" + ] + } + }, + { + "annotations": {}, + "description": null, + "type": "date", + "name": "modification_date", + "label": "Modification date" + }, + { + "annotations": {}, + "description": null, + "type": "text", + "name": "label_en", + "label": "LABEL EN" + }, + { + "description": null, + "label": "Coordinates", + "type": "geo_point_2d", + "name": "coordinates", + "annotations": { + "facetsort": [ + "-count" + ] + } + } + ], + "metas": { + "default": { + "records_count": 137611, + "modified": "2021-06-23T07:50:20+00:00", + "source_domain_address": null, + "references": "https://download.geonames.org/export/dump/", + "keyword": [ + "Geonames", + "city", + "world" + ], + "source_domain_title": null, + "geographic_reference": [ + "world" + ], + "timezone": null, + "title": "Geonames - All Cities with a population > 1000", + "parent_domain": null, + "theme": [ + "Administration, Government, Public finances, Citizenship" + ], + "modified_updates_on_data_change": true, + "metadata_processed": "2021-06-23T07:50:26.162000+00:00", + "data_processed": "2021-06-22T08:47:08+00:00", + "territory": [ + "World" + ], + "description": "All cities with a population > 1000 or seats of adm div (ca 80.000)
Enrichment: