diff --git a/Home.md b/Home.md index 153e97e..8342520 100644 --- a/Home.md +++ b/Home.md @@ -256,3 +256,34 @@ Mobile touch gesture support for the asset list: - **Idempotent init:** `_ptrInited` and `_swipeInited` guards prevent duplicate event listeners on tab switches. **Implementation:** Single consolidated implementation replacing 2 prior conflicting versions. Removed duplicate `let ptrState` declaration that caused SyntaxError. + +## Cantaloupe Sync — Automated Export + Import Pipeline + +**Date:** 2026-05-21 + +The [[canteen-admin-server]] (port 8090, proxy: `admin.canteen.ourpad.casa`) includes a Cantaloupe sync API for staged import of machine data from Cantaloupe Excel exports. + +### Cron Job (`5ababff9c6e9`) +- **Script:** `~/.hermes/scripts/cantaloupe-sync.sh` +- **Schedule:** Every 6 hours +- **Pipeline:** + 1. Runs `python -m cantaloupe export --scheduled --output ~/cantaloupe-exports/` from `~/projects/cantaloupe-downloader/` + 2. Gets admin Bearer token from `/api/auth/login` + 3. Triggers `/api/admin/cantaloupe/sync` to parse, diff, and stage the data +- **Credentials:** `~/.cantaloupe.env` — currently has dummy values; needs real [mycantaloupe.com](https://mycantaloupe.com) account credentials +- **Status:** Active; results saved locally (check cron status for output) + +### Sync API Endpoints +| Method | Path | Description | +|--------|------|-------------| +| POST | `/api/admin/cantaloupe/sync` | Upload Excel or trigger export; parse, diff, stage | +| GET | `/api/admin/cantaloupe/batches` | List all batches (filterable by status) | +| GET | `/api/admin/cantaloupe/batches/{id}` | Full batch detail with row-level diff | +| POST | `/api/admin/cantaloupe/batches/{id}/approve` | Apply staged changes to assets DB | +| POST | `/api/admin/cantaloupe/batches/{id}/reject` | Discard batch | + +### Fix: Export Subprocess CWD (e9d18cb, issue #6) +The `subprocess.run` for cantaloupe export had `cwd` pointing to the admin server directory. The cantaloupe module is a local module at `~/projects/cantaloupe-downloader/` and cannot be imported from the admin server directory. Fixed by changing `cwd` to `os.path.expanduser("~/projects/cantaloupe-downloader")`. + +### Known Issue: Dummy Credentials (issue #7) +`~/.cantaloupe.env` contains dummy values (`user@example.com`). Real [mycantaloupe.com](https://mycantaloupe.com) account credentials needed before the export will work.