mirror of
https://github.com/LearningCircuit/local-deep-research.git
synced 2026-06-15 19:46:56 +03:00
fix: harden DB session handling and ArXiv journal_ref forwarding (Round 3)
- Wrap __save_journal_to_db in try/except to handle DB session failures gracefully (e.g., encrypted DB with wrong password). Score is still valid but won't be cached until next successful DB access. - Explicitly forward journal_ref in ArXiv _get_full_content to prevent fragile reliance on item.copy() preserving the field.
This commit is contained in:
@@ -660,6 +660,52 @@ JOURNAL INFORMATION:
|
||||
if session_ctx is None:
|
||||
# No thread context (preview filter phase) — skip DB save
|
||||
return
|
||||
try:
|
||||
self._save_journal_to_db_inner(
|
||||
session_ctx,
|
||||
name=name,
|
||||
quality=quality,
|
||||
score_source=score_source,
|
||||
h_index=h_index,
|
||||
impact_factor=impact_factor,
|
||||
sjr_quartile=sjr_quartile,
|
||||
is_in_doaj=is_in_doaj,
|
||||
has_doaj_seal=has_doaj_seal,
|
||||
is_predatory=is_predatory,
|
||||
predatory_source=predatory_source,
|
||||
issn=issn,
|
||||
publisher=publisher,
|
||||
openalex_source_id=openalex_source_id,
|
||||
source_type=source_type,
|
||||
is_indexed_in_scopus=is_indexed_in_scopus,
|
||||
)
|
||||
except Exception:
|
||||
logger.warning(
|
||||
f"Failed to save journal '{name}' to DB — "
|
||||
f"score is still valid but won't be cached."
|
||||
)
|
||||
|
||||
def _save_journal_to_db_inner(
|
||||
self,
|
||||
session_ctx,
|
||||
*,
|
||||
name: str,
|
||||
quality: int,
|
||||
score_source: str,
|
||||
h_index: int | None = None,
|
||||
impact_factor: float | None = None,
|
||||
sjr_quartile: str | None = None,
|
||||
is_in_doaj: bool | None = None,
|
||||
has_doaj_seal: bool | None = None,
|
||||
is_predatory: bool | None = None,
|
||||
predatory_source: str | None = None,
|
||||
issn: str | None = None,
|
||||
publisher: str | None = None,
|
||||
openalex_source_id: str | None = None,
|
||||
source_type: str | None = None,
|
||||
is_indexed_in_scopus: bool | None = None,
|
||||
) -> None:
|
||||
"""Inner save logic, separated to wrap DB session errors cleanly."""
|
||||
with session_ctx as db_session:
|
||||
journal = db_session.query(Journal).filter_by(name=name).first()
|
||||
now = int(time.time())
|
||||
|
||||
@@ -251,6 +251,8 @@ class ArXivSearchEngine(BaseSearchEngine):
|
||||
"summary": paper.summary, # Full summary
|
||||
"comment": paper.comment,
|
||||
"doi": paper.doi,
|
||||
# Explicitly forward for journal quality filter
|
||||
"journal_ref": paper.journal_ref,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user