Places API script normalizes regular and special hours; build uses a snapshot, an orari sidecar refreshes /dati/orari.json every 6 hours for the open-now sign. Adds the company legal name. Key stays in .env.server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2.1 KiB
2.1 KiB
ADR 0005: Opening hours from the Google Business Profile via Places API
Status
Accepted (2026-11-04)
Context
Opening hours were hard-coded in the site. The client keeps them up to date on the Google Business Profile listing "Officine Zuliani E. di Peresani A. Tosoni B. & C. S.A.S.", including special closures (holidays, vacations). Having one source avoids mismatches between site and Google (also a local-SEO signal).
Decision
- Read hours with Places API (New) Place Details (
regularOpeningHours,currentOpeningHours,businessStatus) using an API key restricted to Places API. The Business Profile API was rejected: owner OAuth and Google approval are overkill for reading hours. scripts/orari-google.mjsnormalizes the response to the site format:settimana(days grouped by identical time ranges) andprossimiGiorni(actual ranges for the next 7 days, special closures included). On any error it leaves the existing file untouched.- Build time:
deploy.shruns the script and writessrc/data/orari-google.json(committed snapshot). The build uses it for the hours text, the table on /dove-siamo and theopeningHoursSpecificationJSON-LD. If it is missing,src/data/orari.tsfalls back to hard-coded hours. - Runtime: a second container
officinezuliani-orari(node:22-alpine, no custom image) runs the same script every 6 hours and writesorari.jsonto a shared volume served by nginx at/dati/orari.json. The "open now" sign fetches it in the browser and redraws bars and status; if the fetch fails, the build-time hours stay. - The key is never in the repository or in the browser: local
.env.server(git-ignored) → copied bydeploy.shto the server as.env(mode 600).
Consequences
- The client edits hours only on Google; the sign follows within 6 hours, without a deploy. The /dove-siamo table and JSON-LD update at the next deploy.
- About 120 Place Details requests per month: expected to stay within Google Maps Platform free monthly usage, but a billing account is required — check the current price list.
- If Google returns no regular hours, nothing is overwritten (no blank sign).