(
user_metadata: Dict[str, Dict[str, Any]],
roles: Dict[str, Dict[str, Any]],
episode_rows: Sequence[Dict[str, Any]],
)
| 406 | |
| 407 | |
| 408 | def build_profile_map( |
| 409 | user_metadata: Dict[str, Dict[str, Any]], |
| 410 | roles: Dict[str, Dict[str, Any]], |
| 411 | episode_rows: Sequence[Dict[str, Any]], |
| 412 | ) -> Dict[str, Dict[str, Any]]: |
| 413 | user_ids = sorted( |
| 414 | { |
| 415 | str(row.get("user_id") or "").strip() |
| 416 | for row in episode_rows |
| 417 | if str(row.get("user_id") or "").strip() |
| 418 | } |
| 419 | | set(user_metadata.keys()) |
| 420 | ) |
| 421 | profiles: Dict[str, Dict[str, Any]] = {} |
| 422 | for user_id in user_ids: |
| 423 | meta = user_metadata.get(user_id, {"user_id": user_id}) |
| 424 | role_name = str(meta.get("role_name") or user_id.replace("user_", "")).strip() |
| 425 | profiles[user_id] = build_natural_language_profile(meta, roles.get(role_name, {})) |
| 426 | return profiles |
| 427 | |
| 428 | |
| 429 | def clone_output_row( |
no test coverage detected