Skip to content

OPS-REF-002B: Split PostgreSQL source-family parameter mapping#651

Merged
ktalpay merged 1 commit into
developfrom
codex/extract-parameter-mapping-and-json-helpers
Jun 2, 2026
Merged

OPS-REF-002B: Split PostgreSQL source-family parameter mapping#651
ktalpay merged 1 commit into
developfrom
codex/extract-parameter-mapping-and-json-helpers

Conversation

@ktalpay

@ktalpay ktalpay commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Reduce responsibility of postgresql_source_family_repository.py by extracting master/detail parameter mapping and JSON payload helpers into a focused module while preserving runtime orchestration in the repository.
  • Make the parameter mapping reusable and easier to test without changing SQL, schema, UUID logic, or persistence behavior.

Description

  • Added src/carbonfactor_parser/persistence/postgresql_source_family_parameters.py that exposes master_parameters(record), detail_parameters(record), json_payload(value), and json_safe(value) and implements the same tuple layouts and JSON conversion rules as before.
  • Updated src/carbonfactor_parser/persistence/postgresql_source_family_repository.py to call master_parameters and detail_parameters and removed the previous internal helpers from the repository file, keeping orchestration, upserts, transaction helpers, and error redaction in place.
  • master_parameters computes ingestion_run_uuid(record) once into ingestion_id before building the tuple to avoid repeated UUID calls while preserving deterministic behavior.
  • JSON helpers preserve exact behavior: Decimal -> str, mapping keys sorted by string key, tuples/lists recursively converted to lists, and serialization uses sort_keys=True and separators=(",",":").
  • Added focused tests in tests/test_postgresql_source_family_repository.py to assert master/detail tuple lengths/positions, UUID string values, compact metadata/raw/normalized JSON payloads, and json_safe behavior.

Testing

  • Ran python -m pytest tests/test_postgresql_source_family_repository.py and it passed (18 passed, 1 skipped).
  • Ran targeted tests python -m pytest tests/test_configured_cycle_runner.py tests/test_ingestion_run_history_mapping.py tests/test_ingestion_run_history_repository.py tests/test_ingestion_run_history_reader.py and they passed (50 passed).
  • Ran the full test suite python -m pytest and it passed (2159 passed, 8 skipped).
  • Ran python -m ruff check on the changed files and git diff --check, both passed.

Codex Task

@ktalpay
ktalpay merged commit 1691c94 into develop Jun 2, 2026
2 checks passed
@ktalpay
ktalpay deleted the codex/extract-parameter-mapping-and-json-helpers branch June 2, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant