Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions src/analytics_query_analyzer/timebounds_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def __init__(
self.current_date_provider = current_date_provider or date.today

def analyze(self, expression: exp.Expression) -> list[TimeboundsRow]:
return _flatten_timebounds(
_stringify_results(self._analyze_internal(expression))
)
return _flatten_timebounds(self._analyze_internal(expression))

def _analyze_internal(self, expression: exp.Expression) -> TimeboundsResults:
if isinstance(expression, exp.Union):
Expand Down Expand Up @@ -631,20 +629,8 @@ def _normalize_iso_date(value: str) -> date | None:
return None


def _stringify_results(
results: TimeboundsResults,
) -> dict[str, dict[str, str | None]]:
output: dict[str, dict[str, str | None]] = {}
for key, bounds in results.items():
output[key] = {
"lower": bounds["lower"].isoformat() if bounds["lower"] else None,
"upper": bounds["upper"].isoformat() if bounds["upper"] else None,
}
return output


def _flatten_timebounds(
results: dict[str, dict[str, str | None]],
results: TimeboundsResults,
) -> list[TimeboundsRow]:
rows: list[TimeboundsRow] = []
for full_path, bounds in results.items():
Expand Down
5 changes: 3 additions & 2 deletions src/analytics_query_analyzer/types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import date
from typing import TypedDict


Expand All @@ -9,5 +10,5 @@ class ReferenceRow(TypedDict):


class TimeboundsRow(ReferenceRow):
lower: str | None
upper: str | None
lower: date | None
upper: date | None
Loading