(
user_metadata: Dict[str, Dict[str, Any]],
roles: Dict[str, Dict[str, Any]],
episode_rows: Sequence[Dict[str, Any]],
)
| 613 | |
| 614 | |
| 615 | def build_user_states( |
| 616 | user_metadata: Dict[str, Dict[str, Any]], |
| 617 | roles: Dict[str, Dict[str, Any]], |
| 618 | episode_rows: Sequence[Dict[str, Any]], |
| 619 | ) -> Dict[str, UserFeedbackState]: |
| 620 | user_ids = sorted( |
| 621 | { |
| 622 | str(row.get("user_id") or "").strip() |
| 623 | for row in episode_rows |
| 624 | if str(row.get("user_id") or "").strip() |
| 625 | } |
| 626 | | set(user_metadata.keys()) |
| 627 | ) |
| 628 | states: Dict[str, UserFeedbackState] = {} |
| 629 | for user_id in user_ids: |
| 630 | meta = user_metadata.get(user_id, {"user_id": user_id}) |
| 631 | role_name = str(meta.get("role_name") or user_id.replace("user_", "")).strip() |
| 632 | role = roles.get(role_name, {}) |
| 633 | profile = build_initial_profile(meta, role) |
| 634 | states[user_id] = UserFeedbackState(profile=profile, profile_text=make_profile_text(profile)) |
| 635 | return states |
| 636 | |
| 637 | |
| 638 | def clone_output_row( |
no test coverage detected