More changes than expected. Mobile version improvements & PWA
Build & Push Docker Images / test-backend (push) Successful in 44s
Build & Push Docker Images / test-frontend (push) Successful in 52s
Build & Push Docker Images / build-backend (push) Failing after 34s
Build & Push Docker Images / build-frontend (push) Failing after 30s
Build & Push Docker Images / test-backend (push) Successful in 44s
Build & Push Docker Images / test-frontend (push) Successful in 52s
Build & Push Docker Images / build-backend (push) Failing after 34s
Build & Push Docker Images / build-frontend (push) Failing after 30s
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
* Default URL: FARMACIAS_WEBHOOK_URL env or the project webhook.
|
||||
*/
|
||||
|
||||
import { parseOsmOpeningHours } from '../API/opening-hours-osm.js';
|
||||
|
||||
export const DEFAULT_FARMACIAS_WEBHOOK =
|
||||
process.env.FARMACIAS_WEBHOOK_URL ||
|
||||
'https://n8n.hacecalor.net/webhook/farmacias';
|
||||
@@ -120,9 +122,33 @@ export function normalizePharmacyRecord(raw) {
|
||||
phone: phone || null,
|
||||
latitude,
|
||||
longitude,
|
||||
opening_hours: extractOpeningHours(raw),
|
||||
};
|
||||
}
|
||||
|
||||
function extractOpeningHours(raw) {
|
||||
if (!raw || typeof raw !== 'object') return null;
|
||||
const direct = raw.opening_hours;
|
||||
if (direct && typeof direct === 'object' && !Array.isArray(direct)) {
|
||||
return direct;
|
||||
}
|
||||
const candidates = [
|
||||
direct,
|
||||
raw.openingHours,
|
||||
raw.horario,
|
||||
raw.hours,
|
||||
raw.tags?.opening_hours,
|
||||
raw.properties?.opening_hours,
|
||||
];
|
||||
for (const c of candidates) {
|
||||
if (typeof c === 'string' && c.trim()) {
|
||||
const parsed = parseOsmOpeningHours(c);
|
||||
if (parsed) return parsed;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** n8n often returns [{ json: { ... } }, ...] */
|
||||
function unwrapN8nItemArray(arr) {
|
||||
if (!Array.isArray(arr) || arr.length === 0) return arr || [];
|
||||
@@ -209,7 +235,7 @@ export async function importPharmaciesFromRows(dbGet, dbRun, rows) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const { name, address, phone, latitude, longitude } = normalized;
|
||||
const { name, address, phone, latitude, longitude, opening_hours } = normalized;
|
||||
|
||||
try {
|
||||
const existing = await dbGet(
|
||||
@@ -221,9 +247,11 @@ export async function importPharmaciesFromRows(dbGet, dbRun, rows) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const openingHoursValue = opening_hours ? JSON.stringify(opening_hours) : null;
|
||||
|
||||
await dbRun(
|
||||
'INSERT INTO pharmacies (name, address, phone, latitude, longitude) VALUES (?, ?, ?, ?, ?)',
|
||||
[name, address, phone || null, latitude, longitude]
|
||||
'INSERT INTO pharmacies (name, address, phone, latitude, longitude, opening_hours) VALUES (?, ?, ?, ?, ?, ?)',
|
||||
[name, address, phone || null, latitude, longitude, openingHoursValue]
|
||||
);
|
||||
inserted++;
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user