feat: export calendar and backup db

This commit is contained in:
jfmcarreira committed 2026-10-06 15:44:25 +01:00
1 parent 306e21fe44
commit f4985b7fbc
28 files changed
+712 -46

No files matched your search

+13 -1
View File
@@ -9,7 +9,19 @@ This distinction is intentional: editing a rotation must not retroactively chang
## Seeded schedules
Seeded names are Portuguese (`Noite`, `Almoço - Sábados`, `Almoço - Domingo`); the slugs stay `night`, `saturday-lunch` and `sunday-lunch`.
The seeded `label_time` carries the hours the shift runs, shown next to the schedule name: `20:30–00:00` for the night and `13:00–16:00` for both lunches. Both migrations are guarded by slug and previous value, so a label an administrator chose is never overwritten.
Each schedule carries `start_time`/`end_time`, the hours the shift runs, editable by an administrator on its configuration page: `20:30–00:00` for the night and `13:00–16:00` for both lunches. An end at or before the start means the shift runs into the next day.
## Backups
Every start copies the SQLite file aside before anything else runs, using SQLite's own backup API so the copy is consistent. Files go to `backups/` next to the database (or `BACKUP_DIR`), are named `rota-YYYYmmdd-HHMMSS.db` and are never overwritten: two starts in the same second increment the name. Nothing is copied for another engine or an in-memory database, and a failed backup only logs a warning instead of stopping the app. Nothing is ever pruned, so the folder grows one file per start.
## Calendar feeds
- `/calendar/<token>.ics` is an iCalendar feed anybody can subscribe to from Google Calendar, Apple Calendar or Outlook. Every person has their own token, created the first time they open `/calendar`, and their feed only carries the shifts assigned to them.
- `/calendar` is the page holding those links: the rota only has a button pointing there, so it keeps showing nothing but who works each day. Each address sits in a readonly field with a **Copiar** button (clipboard when the browser allows it, selecting the field otherwise) plus a `webcal://` shortcut.
- Administrators also get one shared feed with the whole rota, using the team token in `CALENDAR_TOKEN` (generated on first use and shown on `/admin/schedules`).
- A feed publishes one month back and six months forward, with floating local times so no timezone database is needed. Times and names are private member data: the token is the only protection, so the shared link goes only to the team.
- An unknown token returns 404, and a deactivated person's token stops working.
### Night (`Noite`)