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) <noreply@anthropic.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user