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