fix(perf): normalize outbound quality cutoff
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m51s
CD Pipeline / build-and-deploy (push) Successful in 15m25s
CD Pipeline / post-deploy-checks (push) Successful in 3m5s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Successful in 1s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 22s

This commit is contained in:
Your Name
2026-07-17 05:41:06 +08:00
parent c100a1ca8f
commit e60afe2a05
2 changed files with 10 additions and 1 deletions

View File

@@ -158,6 +158,13 @@ def _inbound_lookup_branch_limit(limit: int) -> int:
return max(1, min(int(limit), _INBOUND_LOOKUP_BRANCH_LIMIT))
def _outbound_database_cutoff(value: datetime) -> datetime:
"""Match the production outbound table's naive-UTC timestamp contract."""
if value.tzinfo is None:
return value
return value.astimezone(UTC).replace(tzinfo=None)
async def _fetch_inbound_conversation_event_rows(
db: Any,
*,
@@ -440,7 +447,7 @@ async def _fetch_outbound_rows_for_incidents(
"incident_ids": source_ids,
}
if cutoff is not None:
base_params["cutoff"] = cutoff
base_params["cutoff"] = _outbound_database_cutoff(cutoff)
async def fetch_branch(
where_sql: str, params: dict[str, Any] | None = None

View File

@@ -233,6 +233,8 @@ async def test_batch_outbound_lookup_never_casts_full_envelope_to_text(
assert all("source_envelope::text" not in sql for sql, _ in calls)
assert all("FROM unnest" not in sql for sql, _ in calls)
assert all("content_preview ILIKE" not in sql for sql, _ in calls)
assert all(params["cutoff"] == cutoff.replace(tzinfo=None) for _, params in calls)
assert all(params["cutoff"].tzinfo is None for _, params in calls)
def test_ansible_audit_keeps_external_incident_id_in_json_not_bigint_column() -> None: