From c4690da2624c158ba386cf1393ad14908263612b Mon Sep 17 00:00:00 2001 From: cproudlock Date: Mon, 13 Jul 2026 13:25:12 -0400 Subject: [PATCH] WJ import loader: resolve notification employee SSOs to names Notifications imported with only employeesso, leaving employeename null - the model displays "employeename or employeesso", so recognition/training cards showed a bare SSO instead of a name. Build an SSO -> "First Last" map from the employee source and populate employeename (comma-separated SSOs -> joined names). SSOs not in the directory (former/non-WJF) stay null and fall back to the SSO, as before. Verified on the import DB: 261 notifications re-imported, names resolved (Brandon Saltz, Jon Kolkmann, ...). Co-Authored-By: Claude Opus 4.8 --- scripts/site_imports/wjf/run.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/site_imports/wjf/run.py b/scripts/site_imports/wjf/run.py index 0dcac3e..7f33215 100644 --- a/scripts/site_imports/wjf/run.py +++ b/scripts/site_imports/wjf/run.py @@ -480,6 +480,23 @@ def stage_notifications(h): h.ids.put('notificationtype', t['notificationtypeid'], newid) counts['notificationtypes'] = h.ids.count('notificationtype') + # SSO -> "First Last" from the employee source, so recognition/training + # notifications display a name, not a bare SSO (the model shows employeename + # or falls back to employeesso). + ssoname = {} + for e in h.source.rows('wjf_employees_src', + 'SELECT SSO, First_Name, Last_Name FROM employees'): + full = f"{(e['First_Name'] or '').strip()} {(e['Last_Name'] or '').strip()}".strip() + if full: + ssoname[str(e['SSO']).strip()] = full + + def _names(employeesso): + if not employeesso: + return None + parts = [ssoname.get(s.strip()) for s in str(employeesso).split(',') if s.strip()] + parts = [p for p in parts if p] + return ', '.join(parts) or None + made = 0 for n in h.source.rows('shopdb_src', 'SELECT notificationtypeid, businessunitid, appid, notification, ' @@ -497,7 +514,8 @@ def stage_notifications(h): 'appid': h.ids.get('app', n['appid']), 'starttime': str(n['starttime']) if n['starttime'] else None, 'endtime': endtime, 'ticketnumber': n['ticketnumber'], 'link': n['link'], - 'isshopfloor': bool(n['isshopfloor']), 'employeesso': n['employeesso']} + 'isshopfloor': bool(n['isshopfloor']), 'employeesso': n['employeesso'], + 'employeename': _names(n['employeesso'])} status, _ = h.post('/api/notifications', payload) if status in (200, 201): made += 1