Skip to content

Commit 7ab2394

Browse files
committed
Separate export lifecycle diagnostics from loss consent
1 parent 1bea277 commit 7ab2394

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/openstatspec/spss/sav.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ def export_sav_dataset(
684684
)
685685
persisted_events = read_fidelity_events(
686686
database_url=database_url, dataset_id=dataset_id,
687+
direction="import",
687688
dolt_conformance_source=dolt_conformance_source,
688689
)
689690
if legacy_locale is not None:

src/openstatspec/sql/wide.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,9 +1322,10 @@ def _export_response_set(
13221322

13231323
def read_fidelity_events(
13241324
*, database_url: str, dataset_id: str,
1325+
direction: str | None = None,
13251326
dolt_conformance_source: Any | None = None,
13261327
) -> tuple[dict[str, Any], ...]:
1327-
"""Read fidelity diagnostics from the normative catalog."""
1328+
"""Read fidelity diagnostics, optionally limited to one lifecycle direction."""
13281329
effective_profile(
13291330
database_url, dolt_conformance_source=dolt_conformance_source,
13301331
)
@@ -1333,12 +1334,18 @@ def read_fidelity_events(
13331334
with engine.connect() as connection:
13341335
require_verified_catalog(connection)
13351336
dataset = _resolve_normative_dataset(connection, normative, dataset_id)
1336-
events = connection.execute(
1337+
statement = (
13371338
select(normative.fidelity_event)
13381339
.where(normative.fidelity_event.c.dataset_id == dataset["dataset_id"])
13391340
.where(normative.fidelity_event.c.severity != "info")
1340-
.order_by(normative.fidelity_event.c.event_code)
1341-
).mappings().all()
1341+
)
1342+
if direction is not None:
1343+
statement = statement.where(
1344+
normative.fidelity_event.c.direction == direction
1345+
)
1346+
events = connection.execute(statement.order_by(
1347+
normative.fidelity_event.c.event_code
1348+
)).mappings().all()
13421349
result = []
13431350
for item in events:
13441351
details = json.loads(item["detail_json"] or "{}")

tests/test_review_transaction_boundary.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def test_export_lifecycle_events_remain_linked_to_the_dataset(tmp_path):
108108
"backup_retained",
109109
"export_failed",
110110
}
111+
assert wide.read_fidelity_events(
112+
database_url=database_url, dataset_id="sample", direction="import",
113+
) == ()
111114
connection = sqlite3.connect(path)
112115
assert connection.execute(
113116
"select count(*) from fidelity_event "

0 commit comments

Comments
 (0)