Return Markdown lines summarising PubChem cache freshness, plus a boolean indicating whether any stale entries were found.
(cache_dir)
| 337 | |
| 338 | |
| 339 | def _freshness_section(cache_dir): |
| 340 | """Return Markdown lines summarising PubChem cache freshness, plus a |
| 341 | boolean indicating whether any stale entries were found.""" |
| 342 | manifest = _load_manifest(cache_dir) |
| 343 | max_age = CACHE_FRESHNESS['max_age_days'] |
| 344 | stale = [] |
| 345 | for key, entry in manifest.items(): |
| 346 | if _is_stale(entry.get('fetched', ''), max_age): |
| 347 | stale.append((key, entry.get('fetched', '?'), entry.get('status', '?'))) |
| 348 | stale.sort(key=lambda t: t[1]) # oldest first |
| 349 | |
| 350 | lines = ['## PubChem cache freshness', ''] |
| 351 | if not manifest: |
| 352 | lines += ['_No `manifest.json` found — cache freshness cannot be checked._', ''] |
| 353 | return lines, False |
| 354 | lines += [ |
| 355 | f'- **Cache entries tracked:** {len(manifest)}', |
| 356 | f'- **Max age before refresh recommended:** {max_age} days', |
| 357 | f'- **Stale entries:** {len(stale)}', |
| 358 | '', |
| 359 | ] |
| 360 | if stale: |
| 361 | lines += [ |
| 362 | ('To refresh stale entries, rebuild with ' |
| 363 | '`COOLPROP_PUBCHEM_REFRESH=stale`. To refresh everything, use ' |
| 364 | '`COOLPROP_PUBCHEM_REFRESH=all`. Override the threshold with ' |
| 365 | '`COOLPROP_PUBCHEM_MAX_AGE_DAYS=<n>`.'), |
| 366 | '', |
| 367 | '| Key | Fetched (UTC) | Status |', |
| 368 | '| --- | --- | --- |', |
| 369 | ] |
| 370 | lines += [f'| `{k}` | {ts} | {st} |' for k, ts, st in stale] |
| 371 | lines.append('') |
| 372 | return lines, bool(stale) |
| 373 | |
| 374 | |
| 375 | def write_geometry_status_report(out_path, cache_dir=None): |
no test coverage detected