(
user_id: str,
days: int = 1,
limit_per_source: Optional[int] = None,
arxiv_categories: Optional[Iterable[Any]] = None,
conferences: Optional[Iterable[Any]] = None,
journals: Optional[Iterable[Any]] = None,
target_date: Optional[str] = None,
progress_callback: Optional[Any] = None,
)
| 1976 | must_read_institutions: Optional[List[str]] = None, |
| 1977 | ) -> Dict[str, Any]: |
| 1978 | updates: Dict[str, Any] = {} |
| 1979 | cleaned_affiliation = str(affiliation or "").strip() |
| 1980 | if cleaned_affiliation: |
| 1981 | updates["affiliation"] = cleaned_affiliation |
| 1982 | core_directions = _parse_weight_text(core_directions_text) |
| 1983 | if core_directions: |
| 1984 | updates["core_directions"] = core_directions |
| 1985 | topic_weights = _parse_weight_text(topic_weights_text) |
| 1986 | if topic_weights: |
| 1987 | updates["topic_weights"] = topic_weights |
| 1988 | |
| 1989 | must_read: Dict[str, List[str]] = {} |
| 1990 | if must_read_keywords is not None: |
| 1991 | must_read["keywords"] = _string_list(must_read_keywords) |
| 1992 | if must_read_authors is not None: |
| 1993 | must_read["authors"] = _string_list(must_read_authors) |
| 1994 | if must_read_institutions is not None: |
| 1995 | must_read["institutions"] = _string_list(must_read_institutions) |
| 1996 | if must_read: |
| 1997 | updates["must_read"] = must_read |
| 1998 | return updates |
| 1999 | |
| 2000 | |
| 2001 | def _apply_manual_profile_updates(user_id: str, updates: Dict[str, Any]) -> None: |
| 2002 | if not updates: |
| 2003 | return |
| 2004 | existing_profile = db_ops.get_profile(user_id) |
| 2005 | profile = existing_profile or { |
| 2006 | "user_id": user_id, |
| 2007 | "version": "0.1", |
| 2008 | "core_directions": {}, |
| 2009 | "topic_weights": {}, |
| 2010 | "must_read": {"authors": [], "institutions": [], "keywords": []}, |
| 2011 | } |
| 2012 | profile["user_id"] = user_id |
| 2013 | if "affiliation" in updates: |
| 2014 | profile["affiliation"] = updates["affiliation"] |
| 2015 | if "core_directions" in updates: |
| 2016 | profile["core_directions"] = updates["core_directions"] |
| 2017 | if "topic_weights" in updates: |
| 2018 | profile["topic_weights"] = updates["topic_weights"] |
| 2019 | if "must_read" in updates: |
| 2020 | must_read = dict(profile.get("must_read") or {}) |
| 2021 | for key, values in updates["must_read"].items(): |
| 2022 | must_read[key] = values |
| 2023 | for key in ("authors", "institutions", "keywords"): |
| 2024 | must_read.setdefault(key, []) |
| 2025 | profile["must_read"] = must_read |
| 2026 | if existing_profile: |
| 2027 | db_ops.update_profile(user_id, profile) |
| 2028 | else: |
| 2029 | db_ops.create_profile(user_id, profile) |
| 2030 | |
| 2031 | |
| 2032 | def create_or_update_profile( |
| 2033 | *, |
| 2034 | user_id: str, |
no test coverage detected