(
user_metadata: Dict[str, Dict[str, Any]],
roles: Dict[str, Dict[str, Any]],
episode_rows: Sequence[Dict[str, Any]],
)
| 504 | |
| 505 | |
| 506 | def build_user_states( |
| 507 | user_metadata: Dict[str, Dict[str, Any]], |
| 508 | roles: Dict[str, Dict[str, Any]], |
| 509 | episode_rows: Sequence[Dict[str, Any]], |
| 510 | ) -> Dict[str, UserCitationState]: |
| 511 | user_ids = sorted( |
| 512 | { |
| 513 | str(row.get("user_id") or "").strip() |
| 514 | for row in episode_rows |
| 515 | if str(row.get("user_id") or "").strip() |
| 516 | } |
| 517 | | set(user_metadata.keys()) |
| 518 | ) |
| 519 | states: Dict[str, UserCitationState] = {} |
| 520 | for user_id in user_ids: |
| 521 | meta = user_metadata.get(user_id, {"user_id": user_id}) |
| 522 | role_name = str(meta.get("role_name") or user_id.replace("user_", "")).strip() |
| 523 | profile = build_initial_profile(meta, roles.get(role_name, {})) |
| 524 | states[user_id] = UserCitationState(profile_text=make_profile_text(profile)) |
| 525 | return states |
| 526 | |
| 527 | |
| 528 | def clone_output_row( |
no test coverage detected