Skip to content

Commit

Permalink
MAJ classement villes.plus
Browse files Browse the repository at this point in the history
  • Loading branch information
mquandalle committed Sep 9, 2023
1 parent 32abff6 commit 8783a21
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 91 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ node_modules
.env
.vercel_build_output/
.vercel
local/
*.tmp
*.tmp.*
data-fetch/miniatures/aides-jeunes-repo

# Generated at build time
src/data
src/lib/data
src/lib/data/*
!src/lib/data/classement-villeplus.json
Binary file added bun.lockb
Binary file not shown.
28 changes: 28 additions & 0 deletions data-fetch/maj-villesplus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { JSDOM } from 'jsdom';
import epci from '@etalab/decoupage-administratif/data/epci.json' assert { type: 'json' };
import { slugify } from '../src/lib/utils.js';
import { writeJsonData } from '../src/scripts/writeData.js';

const source = await fetch('https://www.villes.plus/cyclables/metropoles');
const { document } = new JSDOM(await source.text()).window;

const rawMetropoles = [...document.querySelectorAll('h3')].map((h3) => h3.textContent);

const simplify = (s) =>
slugify(s)
.replace(/[0-9]/g, '')
.replace(/((euro)?metropole|de|)/g, '')
.replace(/(^-+|-+$)/g, '');

const normalizedEpciNames = rawMetropoles.map(
(line) => epci.find(({ nom }) => simplify(nom).includes(simplify(line)))?.nom
);

if (normalizedEpciNames.find((n) => !n)) {
console.log('❌ Missing EPCI:');
console.log(normalizedEpciNames.filter(Boolean).join('\n'));
} else {
console.log("✅ All EPCI's found:");
console.log(normalizedEpciNames.join('\n'));
writeJsonData('classement-villeplus.json', normalizedEpciNames);
}
34 changes: 0 additions & 34 deletions data-fetch/villes.plus/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions jsconfig.json

This file was deleted.

93 changes: 47 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
{
"name": "mesaidesvelo",
"version": "1.0.0",
"scripts": {
"postinstall": "node ./src/scripts/postinstall.js",
"dev": "VITE_SITE=mesaidesvelo.fr vite dev",
"dev:retrofit": "VITE_SITE=aideretrofit.fr vite dev",
"build": "VITE_SITE=mesaidesvelo.fr vite build",
"build:retrofit": "VITE_SITE=aideretrofit.fr vite build",
"preview": "VITE_SITE=mesaidesvelo.fr vite preview",
"sync-entreprises": "node ./data-fetch/entreprises/download-gsheet-data.js",
"sync": "svelte-kit sync",
"test": "npm run test:playwright && npm run test:vitest -- run",
"test:playwright": "npx playwright test tests/navigation.spec.js",
"test:vitest": "vitest",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"type": "module",
"private": true,
"devDependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@playwright/test": "^1.35.1",
"@rollup/plugin-yaml": "^4.1.1",
"@sveltejs/adapter-vercel": "^3.0.1",
"@sveltejs/kit": "^1.21.0",
"mdsvex": "^0.11.0",
"node-fetch": "^3.3.1",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"sharp": "=0.32.1",
"svelte": "^4.0.1",
"typescript": "^5.1.6",
"vite": "^4.3.9",
"vite-plugin-windicss": "^1.9.0",
"vitest": "^0.32.2",
"wget-improved": "^3.4.0",
"yaml": "^2.3.1"
},
"dependencies": {
"@etalab/decoupage-administratif": "^3.0.0",
"fuzzysort": "^2.0.4",
"playwright-aws-lambda": "^0.10.0",
"playwright-core": "^1.35.1",
"publicodes": "^1.0.0-beta.70"
}
"name": "mesaidesvelo",
"version": "1.0.0",
"scripts": {
"postinstall": "node ./src/scripts/postinstall.js",
"dev": "VITE_SITE=mesaidesvelo.fr vite dev",
"dev:retrofit": "VITE_SITE=aideretrofit.fr vite dev",
"build": "VITE_SITE=mesaidesvelo.fr vite build",
"build:retrofit": "VITE_SITE=aideretrofit.fr vite build",
"preview": "VITE_SITE=mesaidesvelo.fr vite preview",
"sync-entreprises": "node ./data-fetch/entreprises/download-gsheet-data.js",
"sync": "svelte-kit sync",
"test": "npm run test:playwright && npm run test:vitest -- run",
"test:playwright": "npx playwright test tests/navigation.spec.js",
"test:vitest": "vitest",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"type": "module",
"private": true,
"devDependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@playwright/test": "^1.35.1",
"@rollup/plugin-yaml": "^4.1.1",
"@sveltejs/adapter-vercel": "^3.0.1",
"@sveltejs/kit": "^1.21.0",
"mdsvex": "^0.11.0",
"node-fetch": "^3.3.1",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"sharp": "=0.32.1",
"svelte": "^4.0.1",
"typescript": "^5.1.6",
"vite": "^4.3.9",
"vite-plugin-windicss": "^1.9.0",
"vitest": "^0.32.2",
"wget-improved": "^3.4.0",
"yaml": "^2.3.1"
},
"dependencies": {
"@etalab/decoupage-administratif": "^3.0.0",
"fuzzysort": "^2.0.4",
"jsdom": "^22.1.0",
"playwright-aws-lambda": "^0.10.0",
"playwright-core": "^1.35.1",
"publicodes": "^1.0.0-beta.70"
}
}
24 changes: 24 additions & 0 deletions src/lib/data/classement-villeplus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
"Eurométropole de Strasbourg",
"Bordeaux Métropole",
"Grenoble-Alpes-Métropole",
"Toulouse Métropole",
"Montpellier Méditerranée Métropole",
"Métropole Toulon-Provence-Méditerranée",
"Orléans Métropole",
"CC du Bassin de Marennes",
"Métropole du Grand Paris",
"CC de la Plaine Dijonnaise",
"Métropole de Lyon",
"Tours Métropole Val de Loire",
"Nantes Métropole",
"Brest Métropole",
"Métropole du Grand Nancy",
"Métropole Européenne de Lille",
"Clermont Auvergne Métropole",
"Metz Métropole",
"Métropole Rouen Normandie",
"Métropole Nice Côte d'Azur",
"Métropole d'Aix-Marseille-Provence",
"Saint-Etienne Métropole"
]
11 changes: 10 additions & 1 deletion src/routes/(front)/(search)/ville/[slug]/+page.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,16 @@ export async function load({ params }) {
};
}

infos.classementVillePlus = classementVilleplus.findIndex((epci) => epci === localisation.epci);
const posClassementVillePlus = classementVilleplus.findIndex(
(epci) => epci === localisation.epci
);

if (posClassementVillePlus > -1) {
infos.classementVillePlus = {
position: posClassementVillePlus + 1,
total: classementVilleplus.length,
};
}

if (barometreFubPerCity[localisation.codeInsee]) {
const labelsFub = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,12 @@
Vous pouvez consultez le détail des notes sur le
<a href="https://barometre.parlons-velo.fr/2021/palmares/">site du baromètre</a>.
</p>
{#if infos.classementVillePlus > -1}
{#if infos.classementVillePlus}
<p>
Par ailleurs {leEPCI} se classe {infos.classementVillePlus + 1}<sup
>{infos.classementVillePlus === 0 ? 'ère' : 'ème'}</sup
>/20 au <a href="https://villes.plus/cyclables">classement ville.plus</a> des villes cyclables.
Par ailleurs {leEPCI} se classe {infos.classementVillePlus.position}<sup
>{infos.classementVillePlus.position === 1 ? 'ère' : 'ème'}</sup
>/{infos.classementVillePlus.total} au
<a href="https://villes.plus/cyclables/metropoles">classement ville.plus</a> des villes cyclables.
Ce classement mesure la part de pistes cyclables sécurisées pour relier les différentes mairies
de la métropole.
</p>
Expand Down
1 change: 0 additions & 1 deletion src/scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
await import('./transform-communes-data.js');
await import('./associate-collectivities.js');
await import('../../data-fetch/miniatures/extract-from-aides-jeunes.js');
await import('../../data-fetch/villes.plus/index.js');
6 changes: 6 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./.svelte-kit/mesaidesvelo.fr/tsconfig.json",
"compilerOptions": {
"types": ["bun-types"]
}
}

0 comments on commit 8783a21

Please sign in to comment.