Skip to content

feat(airflow): clean crawl.requests response_body older than 18 months - #373

Merged
max-ostapenko merged 1 commit into
mainfrom
feat/cleanup-old-response-bodies
Nov 27, 2026
Merged

max-ostapenko merged 1 commit into
mainfrom
feat/cleanup-old-response-bodies

Conversation

@max-ostapenko

Copy link
Copy Markdown
Contributor

Summary

  • Adds a cleanup_old_response_bodies task to the crawl_staging_cleanup Airflow DAG, running alongside staging table truncation once per crawl cycle.
  • Computes the YYYY-MM-01 cutoff partition 18 months back (DEFAULT_RESPONSE_BODY_RETENTION_MONTHS = 18) in Python and runs a single-partition UPDATE ... SET response_body = NULL WHERE date = DATE(@cutoff_date) AND response_body IS NOT NULL (avoids touching/resetting older LONG_TERM partitions and uses the project's default BigQuery slot reservation).
  • Renames DEFAULT_RETENTION_DAYS → DEFAULT_STAGING_RETENTION_DAYS for clarity alongside DEFAULT_RESPONSE_BODY_RETENTION_MONTHS.
  • Adds offline unit tests in tests/test_crawl_cleanup.py.

Test Plan

  • python3 -m py_compile airflow/dags/crawl_staging_cleanup.py airflow/dags/common/crawl_cleanup.py tests/test_crawl_cleanup.py
  • python3 -m unittest discover -s tests -p 'test_*.py' -v (20/20 passed)
  • npm run lint && npm test (Prettier/ESLint/Markdownlint + 9/9 JS tests passed)

@max-ostapenko
max-ostapenko merged commit 8b28ebb into main Nov 27, 2026
6 checks passed
@max-ostapenko
max-ostapenko deleted the feat/cleanup-old-response-bodies branch November 27, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant