Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion site/cds_rdm/inspire_harvester/reports/runs/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@
HARVESTER_RUN_LOGS_MAX_PAGES = 50

_GROUPABLE_LEVELS = frozenset({"ERROR", "WARNING"})
_RECORD_ID_PATTERN = re.compile(r"\[(?:INSPIRE#|inspire_id=)(?P<id>[^\]]+)\]")
# Numeric INSPIRE id only — logger prefixes may also include CDS#… in the same
# brackets, e.g. [INSPIRE#1642662 CDS#c42kw-9f710].
_RECORD_ID_PATTERN = re.compile(r"(?:INSPIRE#|inspire_id=)(?P<id>\d+)")
# Full bracketed logger prefix used when normalizing grouping reasons.
_RECORD_PREFIX_PATTERN = re.compile(
r"\[(?:INSPIRE#\d+|inspire_id=\d+)[^\]]*\]\s*"
)
_SKIP_SUMMARY_SUFFIX = " transformed entries with errors."
_WRITER_PREFIXES = (
"Error while processing entry:",
Expand Down Expand Up @@ -140,6 +146,9 @@ def _extract_record_id(message):
Input: "[INSPIRE#12345] Multiple records match."
Output: "12345"

Input: "[INSPIRE#1642662 CDS#c42kw-9f710] File checksum mismatch."
Output: "1642662"

Input: "Multiple records match."
Output: None
"""
Expand Down Expand Up @@ -228,6 +237,8 @@ def _unwrap_message(message):
reason = compact_text(reason.split(marker, 1)[1])

reason = _peel_string_list(reason)
# Drop the full [INSPIRE#… optional CDS#…] prefix, then any bare id markers.
reason = _RECORD_PREFIX_PATTERN.sub("", reason).strip()
reason = _RECORD_ID_PATTERN.sub("", reason).strip()

for prefix in _WRITER_PREFIXES:
Expand Down
Loading