Skip to content

feat(export): connect job export service to api and cli#6

Merged
jaeyeopme merged 1 commit into
mainfrom
export-api-cli
Jun 6, 2026
Merged

feat(export): connect job export service to api and cli#6
jaeyeopme merged 1 commit into
mainfrom
export-api-cli

Conversation

@jaeyeopme

Copy link
Copy Markdown
Owner

Motivation

The project now has source records, rules, output writers, and run history. This PR connects those pieces through one reusable export service and exposes the same workflow through API and CLI entry points.

Scope

  • Add run_job_export orchestration for the local job export workflow.
  • Add ExportRunRecord so persisted run counts are validated before SQLite insert.
  • Update RunRepository to accept a validated run record instead of loose count arguments.
  • Add POST /exports/jobs through FastAPI.
  • Add clean-data-export-api export jobs and clean-data-export-api serve commands.
  • Add focused tests for service output, API response, CLI response, repository persistence, and count validation.

Out of Scope

  • Generated demo output files.
  • README or public docs status updates.
  • Final demo contract tests.
  • New source entities or integrations.

Modifications

  • Added export_service.py to fetch paginated source jobs, fetch related updates, map, validate, remove duplicates, write reports, persist run history, and return an export summary.
  • Added app.py with a thin FastAPI endpoint that calls the export service.
  • Expanded cli.py with export and serve commands while keeping business rules outside the CLI layer.
  • Added ExportRunRecord and updated repository persistence to store validated run data.

Test Plan

  • uv run pytest tests/test_models.py tests/test_repository.py tests/test_export_service.py tests/test_app.py tests/test_cli.py -v
  • uv run ruff check src/clean_data_export_api/models.py src/clean_data_export_api/repository.py src/clean_data_export_api/export_service.py src/clean_data_export_api/app.py src/clean_data_export_api/cli.py tests/test_models.py tests/test_repository.py tests/test_export_service.py tests/test_app.py tests/test_cli.py
  • uv run basedpyright
  • uv run pytest -v
  • uv run pytest tests/test_export_service.py tests/test_app.py tests/test_cli.py --cov=clean_data_export_api --cov-report=term-missing
  • uv run pytest --cov=clean_data_export_api --cov-report=term-missing --cov-fail-under=90
  • uv run python -m compileall src tests
  • uv run clean-data-export-api export jobs --from-date 2026-06-01 --to-date 2026-06-05 --output-dir <tmp>/outputs --database-path <tmp>/history.sqlite3 --page-size 4
  • git diff --check

Docs Impact

none

ADR Check

  • No architecture or scope decision needs a new or updated ADR.

Result

The same deterministic job export workflow now runs through the reusable service, FastAPI endpoint, and CLI command.

@jaeyeopme
jaeyeopme force-pushed the export-api-cli branch 2 times, most recently from f3eb02b to 3ff0173 Compare June 6, 2026 16:21
Add the reusable job export orchestration path and wire it through FastAPI and Typer. Persist validated export run records before returning the final summary, so count validation lives at the workflow boundary.

Tested: uv run pytest tests/test_models.py tests/test_repository.py tests/test_export_service.py tests/test_app.py tests/test_cli.py -v

Tested: uv run ruff check src/clean_data_export_api/models.py src/clean_data_export_api/repository.py src/clean_data_export_api/export_service.py src/clean_data_export_api/app.py src/clean_data_export_api/cli.py tests/test_models.py tests/test_repository.py tests/test_export_service.py tests/test_app.py tests/test_cli.py

Tested: uv run basedpyright

Tested: uv run pytest -v

Tested: uv run pytest tests/test_export_service.py tests/test_app.py tests/test_cli.py --cov=clean_data_export_api --cov-report=term-missing

Tested: uv run pytest --cov=clean_data_export_api --cov-report=term-missing --cov-fail-under=90

Tested: uv run python -m compileall src tests

Tested: uv run clean-data-export-api export jobs --from-date 2026-06-01 --to-date 2026-06-05 --output-dir <tmp>/outputs --database-path <tmp>/history.sqlite3 --page-size 4

Tested: git diff --check
@jaeyeopme
jaeyeopme merged commit b2b9745 into main Jun 6, 2026
2 checks passed
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