From 6bdef86351d9c3f0e90b41b8fddc6dcd0737ab51 Mon Sep 17 00:00:00 2001 From: Cedric Rossi Date: Mon, 24 Nov 2025 13:47:29 +0100 Subject: [PATCH] chore: rename `defaultCountry` to `defaultGeoZone` --- activities.json | 32 +++++++++++++------------- common/distances/transports.py | 6 +++-- ecobalyse_data/export/textile.py | 2 +- models/process.py | 2 +- public/data/textile/materials.json | 32 +++++++++++++------------- tests/fixtures/activities.json | 8 +++---- tests/snapshots/textile/materials.json | 6 ++--- 7 files changed, 45 insertions(+), 43 deletions(-) diff --git a/activities.json b/activities.json index 8235e78b2..ee2740c72 100644 --- a/activities.json +++ b/activities.json @@ -461,7 +461,7 @@ "textile": [ { "alias": "elasthane", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Elasthane (Lycra)", "geographicOrigin": "Asie - Pacifique", "id": "9973088b-c929-4cc5-894a-1e4d28c161d4", @@ -495,7 +495,7 @@ "textile": [ { "alias": "ei-acrylique", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Production de plexiglas (Polyméthacrylate de méthyle)", "geographicOrigin": "Asie - Pacifique", "id": "49a0bec0-f9f3-42db-a514-a9dcf06a8969", @@ -529,7 +529,7 @@ "textile": [ { "alias": "ei-jute-kenaf", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Production de jute, rouissage", "geographicOrigin": "Asie - Pacifique", "id": "a09b2677-2900-4417-a202-e5f9a1abcce1", @@ -563,7 +563,7 @@ "textile": [ { "alias": "ei-pp", - "defaultCountry": "FR", + "defaultGeozone": "FR", "displayName": "Production de polypropylène, granulés", "geographicOrigin": "Europe", "id": "73ef624d-250e-4a9a-af5d-43505b21b527", @@ -598,7 +598,7 @@ "textile": [ { "alias": "ei-pet", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Production de PET, granulés, amorphe", "geographicOrigin": "Asie - Pacifique", "id": "9dba0e95-0c35-4f8b-9267-62ddf47d4984", @@ -637,7 +637,7 @@ "manufacturerAllocation": 0.5, "recycledQualityRatio": 1 }, - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Production de PET recyclé, granulés, amorphe", "geographicOrigin": "Asie - Pacifique", "id": "8f44c680-1263-4588-b79b-a9e4dc3d8de4", @@ -672,7 +672,7 @@ "textile": [ { "alias": "ei-pa", - "defaultCountry": "FR", + "defaultGeozone": "FR", "displayName": "Production de nylon 6-6", "geographicOrigin": "Europe", "id": "c84280ff-e921-4d5c-92d6-51030bf4f74e", @@ -706,7 +706,7 @@ "textile": [ { "alias": "ei-lin", - "defaultCountry": "FR", + "defaultGeozone": "FR", "displayName": "Production de fibres de lin, rouissage", "geographicOrigin": "Europe", "id": "a52e486c-b67e-40af-8337-e8143cbf9076", @@ -740,7 +740,7 @@ "textile": [ { "alias": "ei-laine-par-defaut", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Laine par défaut", "geographicOrigin": "Asie - Pacifique", "id": "1fc3e17d-5661-429d-a150-7986eae16d9d", @@ -794,7 +794,7 @@ "textile": [ { "alias": "ei-laine-nouvelle-filiere", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Laine nouvelle filière", "geographicOrigin": "Asie - Pacifique", "id": "72e29a61-52a9-4eb5-b3fc-5fb87edea041", @@ -829,7 +829,7 @@ "textile": [ { "alias": "ei-coton", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Production de fibres de coton", "geographicOrigin": "Asie - Pacifique", "id": "62a4d6fb-3276-4ba5-93a3-889ecd3bff84", @@ -865,7 +865,7 @@ "textile": [ { "alias": "ei-coton-organic", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Production de fibres de coton bio", "geographicOrigin": "Asie - Pacifique", "id": "a1c1c2ec-33b1-49d6-bf8e-139e2eb7f097", @@ -900,7 +900,7 @@ "textile": [ { "alias": "ei-chanvre", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Production de chanvre", "geographicOrigin": "Asie - Pacifique", "id": "0c1a4654-b030-4fe1-86b7-d96ce0b85bb8", @@ -934,7 +934,7 @@ "textile": [ { "alias": "ei-viscose", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Fibre de viscose", "geographicOrigin": "Asie - Pacifique", "id": "c087d394-5901-4b03-ba7a-7d4b0db0490c", @@ -993,7 +993,7 @@ "manufacturerAllocation": 0.8, "recycledQualityRatio": 0.5 }, - "defaultCountry": "FR", + "defaultGeozone": "FR", "displayName": "Production de coton recyclé (déchets post-consommation)", "geographicOrigin": "France", "id": "457e9b0d-9eda-4dca-b199-deeb0a154fa9", @@ -1053,7 +1053,7 @@ "manufacturerAllocation": 0.8, "recycledQualityRatio": 0.5 }, - "defaultCountry": "FR", + "defaultGeozone": "FR", "displayName": "Production de coton recyclé (déchets de production)", "geographicOrigin": "Espagne & France", "id": "d3d20384-88fb-4c75-ac12-c647365ac6c5", diff --git a/common/distances/transports.py b/common/distances/transports.py index 328bb91ca..74f2e05b5 100644 --- a/common/distances/transports.py +++ b/common/distances/transports.py @@ -1,11 +1,13 @@ import json +from pathlib import Path from common.distances.CountryDistances import CountryDistances from common.export import load_json +from config import settings INPUT_DISTANCES = "distances_raw.json" -COUNTRIES_OFFICIAL = "../../../public/data/countries.json" -OUTPUT = "../../../public/data/transports.json" +COUNTRIES_OFFICIAL = Path(settings.OUTPUT_DIR) / "geozones.json" +OUTPUT = Path(settings.OUTPUT_DIR) / "transports.json" # dictionary of regions to add with the corresponding country regions = { diff --git a/ecobalyse_data/export/textile.py b/ecobalyse_data/export/textile.py index f21d68aad..84449fd41 100644 --- a/ecobalyse_data/export/textile.py +++ b/ecobalyse_data/export/textile.py @@ -54,7 +54,7 @@ def activity_to_materials(eco_activity: dict) -> List[Material]: name=textile_metadata["name"], primary=textile_metadata.get("primary"), geographic_origin=textile_metadata["geographicOrigin"], - default_country=textile_metadata["defaultCountry"], + default_geozone=textile_metadata["defaultGeozone"], cff=cff, ) ) diff --git a/models/process.py b/models/process.py index 28193b315..ff630343f 100644 --- a/models/process.py +++ b/models/process.py @@ -88,7 +88,7 @@ class Material(EcoModel): origin: str primary: Optional[bool] geographic_origin: str - default_country: str + default_geozone: str cff: Optional[Cff] process_id: uuid.UUID diff --git a/public/data/textile/materials.json b/public/data/textile/materials.json index 005cd3c71..1086e508b 100644 --- a/public/data/textile/materials.json +++ b/public/data/textile/materials.json @@ -2,7 +2,7 @@ { "alias": "ei-chanvre", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "0c1a4654-b030-4fe1-86b7-d96ce0b85bb8", "name": "Chanvre", @@ -14,7 +14,7 @@ { "alias": "ei-laine-par-defaut", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "1fc3e17d-5661-429d-a150-7986eae16d9d", "name": "Laine par défaut", @@ -29,7 +29,7 @@ "manufacturerAllocation": 0.8, "recycledQualityRatio": 0.5 }, - "defaultCountry": "FR", + "defaultGeozone": "FR", "geographicOrigin": "France", "id": "457e9b0d-9eda-4dca-b199-deeb0a154fa9", "name": "Coton recyclé (déchets post-consommation)", @@ -41,7 +41,7 @@ { "alias": "ei-acrylique", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "49a0bec0-f9f3-42db-a514-a9dcf06a8969", "name": "Acrylique", @@ -53,7 +53,7 @@ { "alias": "ei-coton", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "62a4d6fb-3276-4ba5-93a3-889ecd3bff84", "name": "Coton", @@ -65,7 +65,7 @@ { "alias": "ei-laine-nouvelle-filiere", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "72e29a61-52a9-4eb5-b3fc-5fb87edea041", "name": "Laine nouvelle filière", @@ -77,7 +77,7 @@ { "alias": "ei-pp", "cff": null, - "defaultCountry": "FR", + "defaultGeozone": "FR", "geographicOrigin": "Europe", "id": "73ef624d-250e-4a9a-af5d-43505b21b527", "name": "Polypropylène", @@ -92,7 +92,7 @@ "manufacturerAllocation": 0.5, "recycledQualityRatio": 1.0 }, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "8f44c680-1263-4588-b79b-a9e4dc3d8de4", "name": "Polyester recyclé", @@ -104,7 +104,7 @@ { "alias": "elasthane", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "9973088b-c929-4cc5-894a-1e4d28c161d4", "name": "Elasthane (Lycra)", @@ -116,7 +116,7 @@ { "alias": "ei-pet", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "9dba0e95-0c35-4f8b-9267-62ddf47d4984", "name": "Polyester", @@ -128,7 +128,7 @@ { "alias": "ei-jute-kenaf", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "a09b2677-2900-4417-a202-e5f9a1abcce1", "name": "Jute", @@ -140,7 +140,7 @@ { "alias": "ei-coton-organic", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "a1c1c2ec-33b1-49d6-bf8e-139e2eb7f097", "name": "Coton biologique", @@ -152,7 +152,7 @@ { "alias": "ei-lin", "cff": null, - "defaultCountry": "FR", + "defaultGeozone": "FR", "geographicOrigin": "Europe", "id": "a52e486c-b67e-40af-8337-e8143cbf9076", "name": "Lin", @@ -164,7 +164,7 @@ { "alias": "ei-viscose", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "c087d394-5901-4b03-ba7a-7d4b0db0490c", "name": "Viscose", @@ -176,7 +176,7 @@ { "alias": "ei-pa", "cff": null, - "defaultCountry": "FR", + "defaultGeozone": "FR", "geographicOrigin": "Europe", "id": "c84280ff-e921-4d5c-92d6-51030bf4f74e", "name": "Nylon", @@ -191,7 +191,7 @@ "manufacturerAllocation": 0.8, "recycledQualityRatio": 0.5 }, - "defaultCountry": "FR", + "defaultGeozone": "FR", "geographicOrigin": "Espagne & France", "id": "d3d20384-88fb-4c75-ac12-c647365ac6c5", "name": "Coton recyclé (déchets de production)", diff --git a/tests/fixtures/activities.json b/tests/fixtures/activities.json index 9dc5225ec..9f4a641cd 100644 --- a/tests/fixtures/activities.json +++ b/tests/fixtures/activities.json @@ -200,7 +200,7 @@ "textile": [ { "alias": "elasthane", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Elasthane (Lycra)", "geographicOrigin": "Asie - Pacifique", "id": "9973088b-c929-4cc5-894a-1e4d28c161d4", @@ -277,7 +277,7 @@ "manufacturerAllocation": 0.5, "recycledQualityRatio": 1 }, - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Production de PET recyclé, granulés, amorphe", "geographicOrigin": "Asie - Pacifique", "id": "8f44c680-1263-4588-b79b-a9e4dc3d8de4", @@ -331,7 +331,7 @@ "textile": [ { "alias": "ei-acrylique", - "defaultCountry": "CN", + "defaultGeozone": "CN", "displayName": "Production de plexiglas (Polyméthacrylate de méthyle)", "geographicOrigin": "Asie - Pacifique", "id": "f6b6684b-c4ff-4df0-84a4-e09e59d32e5f", @@ -360,7 +360,7 @@ "object": [ { "alias": null, - "defaultCountry": "", + "defaultGeozone": "", "displayName": "Example activity from existing", "id": "0e9c64fe-8a5c-40ba-b60c-ff2b47b56627" } diff --git a/tests/snapshots/textile/materials.json b/tests/snapshots/textile/materials.json index 00776ee8b..c148f3fa8 100644 --- a/tests/snapshots/textile/materials.json +++ b/tests/snapshots/textile/materials.json @@ -5,7 +5,7 @@ "manufacturerAllocation": 0.5, "recycledQualityRatio": 1.0 }, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "8f44c680-1263-4588-b79b-a9e4dc3d8de4", "name": "Polyester recyclé", @@ -17,7 +17,7 @@ { "alias": "elasthane", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "9973088b-c929-4cc5-894a-1e4d28c161d4", "name": "Elasthane (Lycra)", @@ -29,7 +29,7 @@ { "alias": "ei-acrylique", "cff": null, - "defaultCountry": "CN", + "defaultGeozone": "CN", "geographicOrigin": "Asie - Pacifique", "id": "f6b6684b-c4ff-4df0-84a4-e09e59d32e5f", "name": "Acrylique",