From 5458d080c6464a39ba984e04b4bf2db81469d453 Mon Sep 17 00:00:00 2001 From: Suriya Date: Mon, 10 Aug 2026 15:48:41 +0530 Subject: [PATCH] feat: let ops set a miler's legacyuserid through the console Backfilling the jupiter->Doormile rider mapping otherwise needs a direct UPDATE against production, since nothing else writes the column. UpdateMiler already runs behind admin auth and findMilerForConsole's tenant scoping, which is the right gate for an ops-only field: it is set for migrated riders and never by the rider themselves. Confirmed mapping, matched on phone (jupiter userid -> Doormile userid): 852->37 Sivakumar Subramani, 883->38 Rajan A, 897->39 Varun Edward, 950->40 Jayasabesh Kumar S, 1111->41 Murali P, 1114->42 Tamilazhagan K. 852 sat under a different jupiter partner (Xpress-Mdu-Main) than the other five, which looked like it might put him out of scope. He is not: he was migrated to tenant 14 / Nagercoil / hub 18, so a Madurai-side partner is exactly where jupiter would carry him. jupiter's partnerid is a rider hub, not a tenant, so it cannot be used to decide tenant membership. Co-Authored-By: Claude Opus 5 (1M context) --- controllers/adminController.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/controllers/adminController.go b/controllers/adminController.go index ed32b1e..3e3b334 100644 --- a/controllers/adminController.go +++ b/controllers/adminController.go @@ -1843,6 +1843,11 @@ func UpdateMiler(c *fiber.Ctx) error { Displayname string `json:"displayname"` Defaultvehicletype string `json:"defaultvehicletype"` Hubid *int `json:"hubid"` + // Legacyuserid links this rider to their old jupiter userid, so telemetry + // still arriving over the jupiter NATS chain resolves to them. Writable + // here because there is no other way to set it — the column is populated + // by ops for migrated riders, never by the rider themselves. + Legacyuserid *int `json:"legacyuserid"` } req := new(MilerUpdate) @@ -1859,6 +1864,9 @@ func UpdateMiler(c *fiber.Ctx) error { if req.Hubid != nil { profile.Hubid = req.Hubid } + if req.Legacyuserid != nil { + profile.Legacyuserid = req.Legacyuserid + } profile.Updatedat = time.Now() if err := db.DB.Save(profile).Error; err != nil {