Recortar el periodo de las medidas a la fecha de corte

This commit is contained in:
2026-12-03 19:33:13 -06:00
parent 0b1393ad23
commit 663d384032
2 changed files with 54 additions and 2 deletions
+7 -2
View File
@@ -6,7 +6,7 @@ counting a few thousand rows (measures) and ordering the follow-up list."""
import operator
import os
import unicodedata
from datetime import date, datetime
from datetime import date, datetime, timedelta
from typing import Annotated, Any
from dagster_graphql import DagsterGraphQLClient
@@ -540,6 +540,9 @@ def search_measure_report(
event_cutoff: date | None = Query(
None, alias="event-cutoff", description="durations count to this day"
),
period_cutoff: date | None = Query(
None, alias="period-cutoff", description="Include period events through this day"
),
_count: int | None = Query(None),
_offset: int = Query(0),
) -> Response:
@@ -553,7 +556,9 @@ def search_measure_report(
rows = measure_reads.rows(domain.value, found.rows, **found.params)
reports = []
page = _sliced(asked, count, offset)
results = m.evaluate_periods(found, rows, [p for _, p in page], as_of, event_cutoff)
evaluated = [m.Period(p.start, min(p.end, period_cutoff + timedelta(days=1)))
if period_cutoff and period_cutoff < date.max else p for _, p in page]
results = m.evaluate_periods(found, rows, evaluated, as_of, event_cutoff)
for (text, period), result in zip(page, results, strict=True):
report = m.report(found, period, result, as_of)
report.id = f"{f.measure_id(found.id)}-{text.lower()}"