(profile: Optional[Dict[str, Any]])
| 340 | |
| 341 | |
| 342 | def _profile_summary(profile: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: |
| 343 | if not profile: |
| 344 | return None |
| 345 | directions = profile.get("core_directions") or {} |
| 346 | topics = profile.get("topic_weights") or {} |
| 347 | return { |
| 348 | "user_id": profile.get("user_id"), |
| 349 | "version": profile.get("version"), |
| 350 | "updated_at": profile.get("updated_at"), |
| 351 | "core_directions": directions, |
| 352 | "top_directions": sorted(directions.items(), key=lambda item: _to_float(item[1]), reverse=True)[:8], |
| 353 | "top_topics": sorted(topics.items(), key=lambda item: _to_float(item[1]), reverse=True)[:8], |
| 354 | "must_read": profile.get("must_read") or {}, |
| 355 | "drift_state": profile.get("drift_state") or {}, |
| 356 | } |
| 357 | |
| 358 | |
| 359 | def _env_bool(name: str, default: bool = False) -> bool: |
no test coverage detected