(
user_metadata: Dict[str, Dict[str, Any]],
roles: Dict[str, Dict[str, Any]],
episode_rows: Sequence[Dict[str, Any]],
)
| 527 | |
| 528 | |
| 529 | def build_user_states( |
| 530 | user_metadata: Dict[str, Dict[str, Any]], |
| 531 | roles: Dict[str, Dict[str, Any]], |
| 532 | episode_rows: Sequence[Dict[str, Any]], |
| 533 | ) -> Dict[str, UserDiscourseState]: |
| 534 | user_ids = sorted( |
| 535 | { |
| 536 | str(row.get("user_id") or "").strip() |
| 537 | for row in episode_rows |
| 538 | if str(row.get("user_id") or "").strip() |
| 539 | } |
| 540 | | set(user_metadata.keys()) |
| 541 | ) |
| 542 | states: Dict[str, UserDiscourseState] = {} |
| 543 | for user_id in user_ids: |
| 544 | meta = user_metadata.get(user_id, {"user_id": user_id}) |
| 545 | role_name = str(meta.get("role_name") or user_id.replace("user_", "")).strip() |
| 546 | profile = build_initial_profile(meta, roles.get(role_name, {})) |
| 547 | states[user_id] = UserDiscourseState(profile_text=make_profile_text(profile)) |
| 548 | return states |
| 549 | |
| 550 | |
| 551 | def clone_output_row( |
no test coverage detected