Refactored the quote_push process to check for any existing jobMaterials and fail with a log entry and some intelligence so that we don't overwrite anything that has been manually created. Also added another list in the inspector.py code to allow us to view this when it occurs.
This commit is contained in:
+10
-2
@@ -47,9 +47,12 @@ The poller stores all fetched form responses in `form_responses_raw`, then parse
|
||||
- dry-run by default
|
||||
- `--apply` performs live ServiceM8 `jobmaterial.json` creates
|
||||
- refuses duplicate apply when generated material rows already exist for that form response unless `--force` is used
|
||||
- Apply tracking tables in `servicem8_formresponse_poll.db`:
|
||||
- before any live create, checks remote ServiceM8 `/jobmaterial.json` for existing rows on the target `job_uuid`
|
||||
- if remote rows already exist, records a remote-existing incident and creates nothing unless `--force-remote-existing` is explicitly used
|
||||
- Apply/incident tracking tables in `servicem8_formresponse_poll.db`:
|
||||
- `quote_template_apply_runs`
|
||||
- `quote_template_apply_run_rows`
|
||||
- `quote_template_remote_existing_incidents`
|
||||
- Created ServiceM8 job material mappings are recorded in:
|
||||
- `servicem8_quote_materials_state.db`
|
||||
|
||||
@@ -73,15 +76,20 @@ Current apply payload rules:
|
||||
- stores/parses results
|
||||
- applies any parsed Quote Template responses that are not already marked/applied
|
||||
- logs each run under `logs/poll-and-apply-YYYYMMDD-HHMMSS.log`
|
||||
- Safety option now available:
|
||||
- Safety options now available:
|
||||
- `--dry-run` runs the same poll/selection flow, but previews the ServiceM8 `jobmaterial` payloads only
|
||||
- dry-run does **not** write to ServiceM8
|
||||
- dry-run does **not** mark quote responses as applied
|
||||
- live apply blocks if remote ServiceM8 already has jobMaterial rows for the job, logging the captured rows/counts to `quote_template_remote_existing_incidents`
|
||||
- `--recheck-remote-existing` revisits previously blocked rows without overriding the safety gate
|
||||
- `--force-remote-existing` explicitly overrides the remote-existing safety gate and still records a forced incident before creating
|
||||
- Examples:
|
||||
- `./poll_and_apply_quote_templates.sh`
|
||||
- `./poll_and_apply_quote_templates.sh --hours 48`
|
||||
- `./poll_and_apply_quote_templates.sh --since '2026-05-04 08:00:00'`
|
||||
- `./poll_and_apply_quote_templates.sh --dry-run --hours 48`
|
||||
- `./poll_and_apply_quote_templates.sh --recheck-remote-existing --hours 48`
|
||||
- `./poll_and_apply_quote_templates.sh --force-remote-existing --hours 48`
|
||||
|
||||
This is the proposed scheduled entry point for soft release, e.g. every 10–30 minutes. For manual confidence checks, run it with `--dry-run` first, inspect the generated payloads/log, then rerun without `--dry-run` only when ready to apply.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user