Skip to content

Commit 9676aab

Browse files
authored
Merge branch 'main' into feature/#140-fix-the-display-of-the-reservoir-capacity-percentage
2 parents 542860a + 205bc1d commit 9676aab

116 files changed

Lines changed: 2583 additions & 1840 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy-front.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,5 @@ jobs:
6060
with:
6161
app-name: ${{ secrets.AZURE_FRONT_APP_NAME }}
6262
publish-profile: ${{ secrets.AZURE_FRONT_PUBLISH_PROFILE }}
63-
images: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
64-
restart: true
65-
66-
# Warm-up: force ISR regeneration so first real user gets data
67-
- name: Warm-up (force ISR regeneration)
68-
run: |
69-
echo "Waiting for App Service to start..."
70-
sleep 30
71-
curl -s -o /dev/null -w "%{http_code}" https://info-embalse-front-prod-ecguababcfdsepga.westeurope-01.azurewebsites.net/
72-
echo " - Warm-up done, ISR regeneration triggered"
63+
images: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_SHA_TAG }}
64+
restart: true

.github/workflows/deploy-functions.yml

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,20 @@ jobs:
2828
- name: Install dependencies
2929
run: npm ci
3030

31-
# Build all workspace packages first (db, db-model, arcgis, etc.)
32-
# This ensures all internal dependencies generate their dist and type declarations
33-
- name: Build all internal packages
34-
run: npm run build
31+
# Build only the packages needed by Azure Functions (avoids building front/Next.js
32+
# which fails under Corepack/Node 22 due to SWC + packageManager conflict)
33+
- name: Build internal packages for functions
34+
run: |
35+
npm run -w db-model build
36+
npm run -w arcgis build --if-present
37+
npm run -w scraping-cuenca-mediterranea build --if-present
38+
npm run -w scraping-cuenca-cantabrico build --if-present
39+
npm run -w scraping-cuenca-catalana build --if-present
40+
npm run -w scraping-cuenca-duero build --if-present
41+
npm run -w scraping-cuenca-jucar build --if-present
42+
npm run -w scraping-cuenca-segura build --if-present
43+
npm run -w scraping-cuenca-mino-sil build --if-present
44+
npm run -w @embalse-info/db build --if-present
3545
3646
# Build ONLY the functions workspace (TypeScript -> dist/)
3747
# This runs clean + type-check + build
@@ -55,6 +65,13 @@ jobs:
5565
cp -R packages/db-model deploy/packages/db-model
5666
cp -R integrations/arcgis deploy/integrations/arcgis
5767
cp -R integrations/scraping-cuenca-mediterranea deploy/integrations/scraping-cuenca-mediterranea
68+
cp -R integrations/scraping-cuenca-cantabrico deploy/integrations/scraping-cuenca-cantabrico
69+
cp -R integrations/scraping-cuenca-catalana deploy/integrations/scraping-cuenca-catalana
70+
cp -R integrations/scraping-cuenca-duero deploy/integrations/scraping-cuenca-duero
71+
72+
cp -R integrations/scraping-cuenca-jucar deploy/integrations/scraping-cuenca-jucar
73+
cp -R integrations/scraping-cuenca-segura deploy/integrations/scraping-cuenca-segura
74+
cp -R integrations/scraping-cuenca-mino-sil deploy/integrations/scraping-cuenca-mino-sil
5875
5976
# Strip devDependencies and rewrite workspace refs to file: paths
6077
node -e "
@@ -73,7 +90,14 @@ jobs:
7390
patchPkg('deploy/packages/db/package.json', {
7491
'arcgis': 'file:../../integrations/arcgis',
7592
'db-model': 'file:../db-model',
76-
'scraping-cuenca-mediterranea': 'file:../../integrations/scraping-cuenca-mediterranea'
93+
'scraping-cuenca-mediterranea': 'file:../../integrations/scraping-cuenca-mediterranea',
94+
'scraping-cuenca-cantabrico': 'file:../../integrations/scraping-cuenca-cantabrico',
95+
'scraping-cuenca-catalana': 'file:../../integrations/scraping-cuenca-catalana',
96+
'scraping-cuenca-duero': 'file:../../integrations/scraping-cuenca-duero',
97+
98+
'scraping-cuenca-jucar': 'file:../../integrations/scraping-cuenca-jucar',
99+
'scraping-cuenca-segura': 'file:../../integrations/scraping-cuenca-segura',
100+
'scraping-cuenca-mino-sil': 'file:../../integrations/scraping-cuenca-mino-sil'
77101
});
78102
79103
// arcgis: point db-model to file: path
@@ -86,6 +110,36 @@ jobs:
86110
'db-model': 'file:../../packages/db-model'
87111
});
88112
113+
// scraping-cuenca-cantabrico: point db-model to file: path
114+
patchPkg('deploy/integrations/scraping-cuenca-cantabrico/package.json', {
115+
'db-model': 'file:../../packages/db-model'
116+
});
117+
118+
// scraping-cuenca-catalana: point db-model to file: path
119+
patchPkg('deploy/integrations/scraping-cuenca-catalana/package.json', {
120+
'db-model': 'file:../../packages/db-model'
121+
});
122+
123+
// scraping-cuenca-duero: point db-model to file: path
124+
patchPkg('deploy/integrations/scraping-cuenca-duero/package.json', {
125+
'db-model': 'file:../../packages/db-model'
126+
});
127+
128+
// scraping-cuenca-jucar: point db-model to file: path
129+
patchPkg('deploy/integrations/scraping-cuenca-jucar/package.json', {
130+
'db-model': 'file:../../packages/db-model'
131+
});
132+
133+
// scraping-cuenca-segura: point db-model to file: path
134+
patchPkg('deploy/integrations/scraping-cuenca-segura/package.json', {
135+
'db-model': 'file:../../packages/db-model'
136+
});
137+
138+
// scraping-cuenca-mino-sil: point db-model to file: path
139+
patchPkg('deploy/integrations/scraping-cuenca-mino-sil/package.json', {
140+
'db-model': 'file:../../packages/db-model'
141+
});
142+
89143
// db-model: just strip devDeps
90144
patchPkg('deploy/packages/db-model/package.json');
91145
"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ __queuestorage__/
88
__tablestorage__/
99
mongo-data
1010
.env
11-
deploy
11+
deploy
12+
front/.env.local

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# embalse-info
22

3+
## Configuración del Front
4+
5+
Al ejecutar `npm install` dentro de la carpeta `front`, se creará automáticamente el fichero `.env.local` a partir de `.env.local.example` (si no existe ya).
6+
7+
Una vez creado, debes configurar el token de Content Island:
8+
9+
1. Abre el fichero `front/.env.local`.
10+
2. Pregunta al equipo de desarrollo cuál es el valor del token de Content Island.
11+
3. Sustituye el valor `VALUE` en la entrada `CONTENT_ISLAND_ACCESS_TOKEN` por el token proporcionado.
12+
13+
```
14+
CONTENT_ISLAND_ACCESS_TOKEN=<token proporcionado por el equipo>
15+
```
16+
317
## Pasos para actualizar la semilla de las cuencas
418

519
```bash

front/.env.local

Lines changed: 0 additions & 1 deletion
This file was deleted.

front/.env.local.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MONGODB_CONNECTION_STRING=mongodb://localhost:27017/embalse-info
2+
3+
4+
# IMPORTANT: ask the team
5+
CONTENT_ISLAND_ACCESS_TOKEN=VALUE
6+

front/Dockerfile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,26 @@ COPY front/package.json ./front/package.json
1212
COPY packages/db-model/package.json ./packages/db-model/package.json
1313

1414
# 2) Install all dependencies for the monorepo (npm workspaces)
15-
# We need dev deps here because Next build typically requires them.
16-
RUN npm ci
15+
# --ignore-scripts: postinstall scripts can't run yet (source not copied)
16+
RUN npm ci --ignore-scripts
1717

1818
# 3) Now copy the full source code
1919
COPY . .
2020

21-
# 4) Build the internal dependency used by the front (db-model)
22-
# If your workspace name differs, adjust "-w db-model"
21+
# 4) Remove packageManager field to prevent Corepack (Node 22) from
22+
# hijacking yarn calls that Next.js SWC patching makes internally.
23+
# Then rebuild native modules (e.g. @tailwindcss/oxide) that were
24+
# skipped by --ignore-scripts above.
25+
# Finally, install the musl binary for tailwindcss/oxide
26+
# (the lock file only has darwin-arm64, not linux-x64-musl).
27+
RUN node -e "const p='package.json',j=JSON.parse(require('fs').readFileSync(p));delete j.packageManager;require('fs').writeFileSync(p,JSON.stringify(j,null,2))" \
28+
&& npm rebuild \
29+
&& cd front && npm install @tailwindcss/oxide-linux-x64-musl --no-save
30+
31+
# 5) Build the internal dependency used by the front (db-model)
2332
RUN npm run -w db-model build --if-present
2433

25-
# 5) Build Next.js (standalone output will be generated)
34+
# 6) Build Next.js (standalone output will be generated)
2635
RUN npm run -w front build
2736

2837

front/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7+
"postinstall": "node scripts/postinstall.js",
78
"start": "next dev",
89
"build": "next build",
910
"start-prod": "node .next/standalone/server.js"
1011
},
1112
"dependencies": {
13+
"@content-island/api-client": "^0.16.0",
1214
"@fontsource/nunito-sans": "^5.2.7",
1315
"@tailwindcss/postcss": "^4.1.17",
1416
"d3": "^7.9.0",
17+
"db-model": "file:../packages/db-model",
1518
"downshift": "^9.2.0",
19+
"mongodb": "^6.12.0",
1620
"next": "^16.1.6",
1721
"postcss": "^8.5.6",
1822
"react": "^19.1.0",
1923
"react-dom": "^19.1.0",
20-
"tailwindcss": "^4.1.17",
21-
"mongodb": "^6.12.0",
22-
"db-model": "file:../packages/db-model"
24+
"tailwindcss": "^4.1.17"
2325
},
2426
"devDependencies": {
2527
"@types/react": "^19.1.8",

front/scripts/postinstall.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { existsSync, copyFileSync } from "node:fs";
2+
import { resolve, dirname } from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
5+
const __dirname = dirname(fileURLToPath(import.meta.url));
6+
const rootDir = resolve(__dirname, "..");
7+
const envLocalPath = resolve(rootDir, ".env.local");
8+
const envExamplePath = resolve(rootDir, ".env.local.example");
9+
10+
if (!existsSync(envLocalPath)) {
11+
copyFileSync(envExamplePath, envLocalPath);
12+
console.log(".env.local created from .env.local.example");
13+
} else {
14+
console.log(".env.local already exists, skipping copy");
15+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { EmbalsesCuencaPod, getEmbalsesPorCuenca } from "@/pods/embalse-cuenca";
2+
import { cuencas } from "@/core/constants";
3+
import { mapLookupListFromApiToViewModel } from "@/common/mappers";
4+
import { Metadata } from "next";
5+
6+
export const revalidate = 300; // ISR: regenerar cada 5 minutos
7+
8+
interface Props {
9+
params: Promise<{ cuenca: string }>;
10+
}
11+
12+
const getCuencaBySlug = (slug: string) => {
13+
return Object.values(cuencas).find((cuenca) => cuenca.slug === slug);
14+
};
15+
16+
export async function generateMetadata({ params }: Props): Promise<Metadata> {
17+
const { cuenca } = await params;
18+
const datosCuenca = getCuencaBySlug(cuenca);
19+
20+
if (!datosCuenca) {
21+
return {};
22+
}
23+
24+
return {
25+
title: `Embalses de ${datosCuenca.nombre}`,
26+
};
27+
}
28+
29+
export default async function EmbalseCuencaListadoPage({
30+
params,
31+
}: Props): Promise<React.JSX.Element> {
32+
const { cuenca } = await params;
33+
const datosCuenca = getCuencaBySlug(cuenca);
34+
35+
const embalsesPorCuencaDesdeApi = await getEmbalsesPorCuenca(
36+
datosCuenca.nombre,
37+
);
38+
const embalsesPorCuenca = mapLookupListFromApiToViewModel(
39+
embalsesPorCuencaDesdeApi,
40+
);
41+
42+
return (
43+
<EmbalsesCuencaPod
44+
nombreCuenca={datosCuenca.nombre}
45+
embalses={embalsesPorCuenca}
46+
/>
47+
);
48+
}

0 commit comments

Comments
 (0)