(
*,
start_date: str,
end_date: str,
sources: Optional[List[str]],
limit_per_source: Optional[int],
)
| 51 | |
| 52 | |
| 53 | def precollect_by_day( |
| 54 | *, |
| 55 | start_date: str, |
| 56 | end_date: str, |
| 57 | sources: Optional[List[str]], |
| 58 | limit_per_source: Optional[int], |
| 59 | ) -> None: |
| 60 | start = _parse_day(start_date) |
| 61 | end = _parse_day(end_date) |
| 62 | if end < start: |
| 63 | raise ValueError("--end-date must be >= --start-date") |
| 64 | |
| 65 | print(f"Pre-collecting papers from {start.date()} to {end.date()}") |
| 66 | print(f"Sources: {sources or ['arxiv', 'openreview', 'journal']}") |
| 67 | print(f"Limit per source: {limit_per_source if limit_per_source is not None else 'collector default'}") |
| 68 | print(f"Initial DB papers: {_count_total_papers()}") |
| 69 | |
| 70 | current = start |
| 71 | days = 0 |
| 72 | total_reported_new = 0 |
| 73 | while current <= end: |
| 74 | day_key = current.strftime("%Y%m%d") |
| 75 | day_label = current.strftime("%Y-%m-%d") |
| 76 | before_day_count = _count_papers_for_day(current) |
| 77 | print("\n" + "=" * 72) |
| 78 | print(f"[{day_label}] collecting one-day paper cache") |
| 79 | print(f"[{day_label}] existing papers for this date: {before_day_count}") |
| 80 | |
| 81 | reported_new = collect_all_papers( |
| 82 | start_date=day_key, |
| 83 | end_date=day_key, |
| 84 | sources=sources, |
| 85 | limit_per_source=limit_per_source, |
| 86 | ) |
| 87 | |
| 88 | after_day_count = _count_papers_for_day(current) |
| 89 | print( |
| 90 | f"[{day_label}] collector reported new={reported_new}; " |
| 91 | f"date_count {before_day_count} -> {after_day_count}" |
| 92 | ) |
| 93 | |
| 94 | total_reported_new += int(reported_new or 0) |
| 95 | days += 1 |
| 96 | current += timedelta(days=1) |
| 97 | |
| 98 | print("\n" + "=" * 72) |
| 99 | print(f"Pre-collection complete: {days} days") |
| 100 | print(f"Collector reported total new papers: {total_reported_new}") |
| 101 | print(f"Final DB papers: {_count_total_papers()}") |
| 102 | |
| 103 | |
| 104 | def main() -> None: |
no test coverage detected