Skip to content

Commit 2e51cdf

Browse files
authored
Merge pull request #123 from Lemoncode/feature/deploy-front
update
2 parents a7f1312 + 5cf2798 commit 2e51cdf

2 files changed

Lines changed: 34 additions & 19 deletions

File tree

.github/workflows/deploy-front.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ jobs:
6262
publish-profile: ${{ secrets.AZURE_FRONT_PUBLISH_PROFILE }}
6363
images: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
6464
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"

front/src/pods/embalse-search/embalse-search.repository.ts

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,34 @@ import { getDb } from "@/lib/mongodb";
44
import type { Embalse } from "./api/api.model";
55

66
export async function getEmbalsesFromDb(): Promise<Embalse[]> {
7-
const db = await getDb();
8-
const docs = await db
9-
.collection("embalses")
10-
.find(
11-
{},
12-
{
13-
projection: {
14-
_id: 1,
15-
nombre: 1,
16-
provincia: 1,
17-
slug: 1,
7+
try {
8+
const db = await getDb();
9+
const docs = await db
10+
.collection("embalses")
11+
.find(
12+
{},
13+
{
14+
projection: {
15+
_id: 1,
16+
nombre: 1,
17+
provincia: 1,
18+
slug: 1,
19+
},
1820
},
19-
},
20-
)
21-
.toArray();
21+
)
22+
.toArray();
2223

23-
return docs.map((doc) => ({
24-
_id: doc.slug ?? createSlug(doc.nombre ?? ""),
25-
nombre: doc.nombre ?? "",
26-
provincia: doc.provincia ?? "",
27-
}));
24+
return docs.map((doc) => ({
25+
_id: doc.slug ?? createSlug(doc.nombre ?? ""),
26+
nombre: doc.nombre ?? "",
27+
provincia: doc.provincia ?? "",
28+
}));
29+
} catch {
30+
console.warn(
31+
"getEmbalsesFromDb: MongoDB not available (build time?), returning empty array"
32+
);
33+
return [];
34+
}
2835
}
2936

3037
const createSlug = (nombre: string): string => {

0 commit comments

Comments
 (0)