Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +23 -22
src/streamlit_app.py
CHANGED
|
@@ -423,28 +423,29 @@ def fetch_employees(employee_ids: Iterable[int]) -> pd.DataFrame:
|
|
| 423 |
|
| 424 |
|
| 425 |
# --- Certifications ---
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
|
|
|
| 448 |
|
| 449 |
|
| 450 |
return {
|
|
|
|
| 423 |
|
| 424 |
|
| 425 |
# --- Certifications ---
|
| 426 |
+
|
| 427 |
+
cert_url = f"{base_url}certifications/{emp_id}"
|
| 428 |
+
cert_resp = requests.get(cert_url, headers=headers)
|
| 429 |
+
certs = []
|
| 430 |
+
if cert_resp.status_code == 200:
|
| 431 |
+
cert_data = cert_resp.json()
|
| 432 |
+
if isinstance(cert_data, list):
|
| 433 |
+
# Already a simple list of cert objects
|
| 434 |
+
for c in cert_data:
|
| 435 |
+
qual = c.get("qualifier")
|
| 436 |
+
if qual:
|
| 437 |
+
certs.append(qual)
|
| 438 |
+
elif isinstance(cert_data, dict) and "assignments" in cert_data:
|
| 439 |
+
# Parse UKG's assignments format
|
| 440 |
+
for a in cert_data.get("assignments", []):
|
| 441 |
+
cert_obj = a.get("certification", {})
|
| 442 |
+
qual = cert_obj.get("qualifier")
|
| 443 |
+
if qual:
|
| 444 |
+
certs.append(qual)
|
| 445 |
+
else:
|
| 446 |
+
st.warning(f"Unrecognized cert format for {emp_id}: {cert_data}")
|
| 447 |
+
else:
|
| 448 |
+
st.warning(f"⚠️ Could not fetch certifications for {emp_id}")
|
| 449 |
|
| 450 |
|
| 451 |
return {
|