gigafibre-fsm/scripts/migration/diag_dispatch_addr.sql
louispaulb e51007327d feat(dispatch): pont d'écriture legacy + adresses/coords/carte/UX Planification
Pont d'écriture Ops → legacy osTicket via endpoint PHP token-gated (hérite des
droits write de l'app facturation.targo.ca → AUCUN grant DB). Fidèle à ticket_view.php :
réassignation (assign_to + participant[assistants] + followed_by + ticket_msg + lock
respecté) + fermeture (status=closed + date_closed + closed_by + réouverture des enfants).
Auteur du log = utilisateur Authentik réel (email → staff legacy par email/nom).

Hub (legacy-dispatch-sync.js):
- adresse de SERVICE importée (champ address) + reimportAddresses + fillMissingCoords
- garde TERRITOIRE (rejette les homonymes hors-zone Gaspésie/Outaouais/Estrie) + centroïde CP/ville
- purgeStaleOrphans (anciens imports TT- périmés), # ticket legacy dans titre + description
- legacyWrite (POST form + X-Ops-Token lu d'un fichier), pushAssignments (reassign), closeTicketLegacy
roster.js: occupancy + unassigned-jobs exposent address/latitude/longitude.

Ops (PlanificationPage.vue):
- carte des jobs à assigner (pins couleur=compétence + lettre repère liste↔carte), chips
  filtre par type, panneau ouvert par défaut
- clics cellule: bande quart/garde + blocs jobs → tournée ; fond → menu horaire (fini le clic droit)
- éditeur de tournée: itinéraire routier réel + adresse + fil ticket (expand), refresh occupation à l'assignation
- bouton « Publier au legacy » (aperçu + ✕ désassigner) + « Fermer le ticket »
- fix dates (lundi calculé en local — plus de décalage UTC) + nav ±1 jour

services/legacy-bridge/ops_reassign.php: endpoint (placeholders; secrets injectés au déploiement, hors repo).
scripts/migration: backfill_dispatch_address.sql + diagnostics.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-07 22:32:00 -04:00

26 lines
1.4 KiB
SQL

-- diag_dispatch_addr.sql — état des adresses/coords des Dispatch Jobs issus du pont legacy.
\timing on
-- 1) Champs « adresse » présents sur le doctype Dispatch Job ?
SELECT column_name FROM information_schema.columns
WHERE table_name = 'tabDispatch Job'
AND (column_name ILIKE '%address%' OR column_name ILIKE '%location%'
OR column_name ILIKE '%civic%' OR column_name ILIKE '%street%'
OR column_name ILIKE '%zip%' OR column_name ILIKE '%postal%' OR column_name ILIKE '%city%')
ORDER BY 1;
-- 2) État des jobs issus du pont (legacy_ticket_id non vide)
SELECT
count(*) AS total_bridge,
count(*) FILTER (WHERE latitude IS NULL OR longitude IS NULL OR abs(coalesce(latitude,0)) < 1) AS sans_coords,
count(*) FILTER (WHERE coalesce(service_location,'') = '') AS sans_service_location,
count(*) FILTER (WHERE coalesce(service_location,'') = '' AND (latitude IS NULL OR abs(coalesce(latitude,0)) < 1)) AS ni_sl_ni_coords
FROM "tabDispatch Job"
WHERE coalesce(legacy_ticket_id,'') <> '';
-- 3) Échantillon de jobs sans coords (que voit-on dans le sujet ?)
SELECT name, legacy_ticket_id, left(subject, 80) AS subject, service_location,
round(latitude::numeric,4) AS lat, round(longitude::numeric,4) AS lon, status
FROM "tabDispatch Job"
WHERE coalesce(legacy_ticket_id,'') <> '' AND (latitude IS NULL OR abs(coalesce(latitude,0)) < 1)
ORDER BY modified DESC LIMIT 12;