Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

refactor(insights): consolidate interval knowledge into one registry (#68287)

Sam Pennington9d93734f698d
diff --git a/frontend/src/lib/components/IntervalFilter/intervals.ts b/frontend/src/lib/components/IntervalFilter/intervals.ts
index 60dff41c79ec..26d65675b2fc 100644
--- a/frontend/src/lib/components/IntervalFilter/intervals.ts
+++ b/frontend/src/lib/components/IntervalFilter/intervals.ts
@@ -1,4 +1,8 @@
-export type IntervalKeyType = 'minute' | 'hour' | 'day' | 'week' | 'month'
+import type { IntervalType } from '~/types'
+
+// Derived from IntervalType so the compiler forces a picker decision when the schema gains an interval.
+// 'second' is intentionally not selectable in the UI.
+export type IntervalKeyType = Exclude<IntervalType, 'second'>
export type Intervals = {
[key in IntervalKeyType]: {
diff --git a/posthog/caching/utils.py b/posthog/caching/utils.py
index 03082b827307..fc2f3464b40c 100644
--- a/posthog/caching/utils.py
+++ b/posthog/caching/utils.py
@@ -5,6 +5,7 @@ from typing import Any, Optional, Union
from dateutil.parser import isoparse, parser
from posthog.clickhouse.client import sync_execute
+from posthog.interval_specs import INTERVAL_SPECS
from posthog.models.filters.filter import Filter
from posthog.models.filters.path_filter import PathFilter
from posthog.models.filters.retention_filter import RetentionFilter
@@ -142,19 +143,11 @@ class ThresholdMode(Enum):
staleness_threshold_map: dict[ThresholdMode, dict[Optional[str], timedelta]] = {
ThresholdMode.DEFAULT: {
None: timedelta(hours=6),
- "minute": timedelta(minutes=5),
- "hour": timedelta(hours=1),
- "day": timedelta(hours=6),
- "week": timedelta(days=1),
- "month": timedelta(days=1),
+ **{name: spec.staleness_default for name, spec in INTERVAL_SPECS.items() if spec.staleness_default is not None},
},
ThresholdMode.LAZY: {
None: timedelta(hours=12),
- "minute": timedelta(minutes=15),
- "hour": timedelta(hours=2),
- "day": timedelta(hours=12),
- "week": timedelta(days=1),
- "month": timedelta(days=1),
+ **{name: spec.staleness_lazy for name, spec in INTERVAL_SPECS.items() if spec.staleness_lazy is not None},
},
ThresholdMode.AI: {
None: timedelta(hours=1),
diff --git a/posthog/hogql_queries/insights/funnels/funnel_trends.py b/posthog/hogql_queries/insights/funnels/funnel_trends.py
index 85d479e9f6fd..f6d67695b04b 100644
--- a/posthog/hogql_queries/insights/funnels/funnel_trends.py
+++ b/posthog/hogql_queries/insights/funnels/funnel_trends.py
@@ -17,8 +17,9 @@ from posthog.hogql_queries.insights.utils.breakdowns import NOT_IN_COHORT_ID
from posthog.hogql_queries.insights.utils.utils import get_start_of_interval_hogql, get_start_of_interval_hogql_str
from posthog.hogql_queries.utils.query_date_range import QueryDateRange
from posthog.hogql_queries.utils.timestamp_utils import format_label_date, get_earliest_timestamp_unfiltered
+from posthog.interval_specs import get_interval_func
from posthog.queries.breakdown_props import get_breakdown_cohort_name
-from posthog.queries.util import correct_result_for_sampling, get_interval_func_ch
+from posthog.queries.util import correct_result_for_sampling
from posthog.utils import DATERANGE_MAP, relative_date_parse
@@ -470,7 +471,7 @@ class FunnelTrendsUDF(FunnelUDFMixin, FunnelBase):
name="assumeNotNull",
args=[ast.Call(name="toDateTime", args=[(ast.Constant(value=formatted_date_to))])],
)
- interval_func = get_interval_func_ch(interval.value)
+ interval_func = get_interval_func(interval.value)
fill_select: list[ast.Expr] = [
ast.Alias(
diff --git a/posthog/hogql_queries/insights/utils/utils.py b/posthog/hogql_queries/insights/utils/utils.py
index b533b9b432fb..8f9735eae8d4 100644
--- a/posthog/hogql_queries/insights/utils/utils.py
+++ b/posthog/hogql_queries/insights/utils/utils.py
@@ -18,12 +18,12 @@ from posthog.hogql.printer import to_printed_hogql
from posthog.hogql.timings import HogQLTimings
from posthog.hogql_queries.utils.query_date_range import compare_interval_length
+from posthog.interval_specs import get_trunc_func
from posthog.models.team.team import Team, WeekStartDay
-from posthog.queries.util import get_trunc_func_ch
def get_start_of_interval_hogql(interval: str, *, team: Team, source: Optional[ast.Expr] = None) -> ast.Expr:
- trunc_func = get_trunc_func_ch(interval)
+ trunc_func = get_trunc_func(interval)
trunc_func_args: list[ast.Expr] = [source] if source else [ast.Field(chain=["timestamp"])]
if trunc_func == "toStartOfWeek":
trunc_func_args.append(ast.Constant(value=int((WeekStartDay(team.week_start_day or 0)).clickhouse_mode)))
@@ -31,7 +31,7 @@ def get_start_of_interval_hogql(interval: str, *, team: Team, source: Optional[a
def get_start_of_interval_hogql_str(interval: str, *, team: Team, source: str) -> str:
- trunc_func = get_trunc_func_ch(interval)
+ trunc_func = get_trunc_func(interval)
return f"{trunc_func}({source}{f', {int((WeekStartDay(team.week_start_day or 0)).clickhouse_mode)}' if trunc_func == 'toStartOfWeek' else ''})"
diff --git a/posthog/hogql_queries/utils/query_date_range.py b/posthog/hogql_queries/utils/query_date_range.py
index 924606043763..eeb0a2937f1c 100644
--- a/posthog/hogql_queries/utils/query_date_range.py
+++ b/posthog/hogql_queries/utils/query_date_range.py
@@ -9,20 +9,10 @@ from posthog.schema import DateRange, IntervalType
from posthog.hogql.parser import ast
+from posthog.interval_specs import ORDERED_INTERVALS, PERIOD_MAP, IntervalLiteral, get_trunc_func, interval_spec
from posthog.models.team import Team, WeekStartDay
-from posthog.queries.util import get_trunc_func_ch
from posthog.utils import DEFAULT_DATE_FROM_DAYS, relative_date_parse, relative_date_parse_with_delta_mapping
-IntervalLiteral = Literal["second", "minute", "hour", "day", "week", "month"]
-ORDERED_INTERVALS = [
- IntervalType.SECOND,
- IntervalType.MINUTE,
- IntervalType.HOUR,
- IntervalType.DAY,
- IntervalType.WEEK,
- IntervalType.MONTH,
-]
-
def compare_interval_length(
interval1: IntervalType, operator: Literal["<", "<=", "=", ">", ">="], interval2: IntervalType
@@ -205,35 +195,12 @@ class QueryDateRange:
return self._date_range.explicitDate
def align_with_interval(self, start: datetime, *, interval_name: Optional[IntervalLiteral] = None) -> datetime:
- interval_name = interval_name or self.interval_name
-
- if interval_name == "second":
- return start.replace(microsecond=0)
- if interval_name == "minute":
- return start.replace(second=0, microsecond=0)
- if interval_name == "hour":
- return start.replace(minute=0, second=0, microsecond=0)
- elif interval_name == "day":
- return start.replace(hour=0, minute=0, second=0, microsecond=0)
- elif interval_name == "week":
- start = start.replace(hour=0, minute=0, second=0, microsecond=0)
- week_start_alignment_days = start.isoweekday() % 7
- if self._team.week_start_day == WeekStartDay.MONDAY:
- week_start_alignment_days = start.weekday()
- start -= timedelta(days=week_start_alignment_days)
- return start
- elif interval_name == "month":
- return start.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
+ spec = interval_spec(interval_name or self.interval_name)
+ return spec.align(start, self._team.week_start_day)
def interval_relativedelta(self) -> relativedelta:
- return relativedelta(
- days=self.interval_count if self.interval_name == "day" else 0,
- weeks=self.interval_count if self.interval_name == "week" else 0,
- months=self.interval_count if self.interval_name == "month" else 0,
- hours=self.interval_count if self.interval_name == "hour" else 0,
- minutes=self.interval_count if self.interval_name == "minute" else 0,
- seconds=self.interval_count if self.interval_name == "second" else 0,
- )
+ spec = interval_spec(self.interval_name)
+ return relativedelta(**{spec.relativedelta_kwarg: self.interval_count}) # type: ignore[arg-type]
def all_values(self, *, interval_name: Optional[IntervalLiteral] = None) -> list[datetime]:
start = self.align_with_interval(self.date_from(), interval_name=interval_name)
@@ -271,19 +238,20 @@ class QueryDateRange:
def one_interval_period(self) -> ast.Expr:
return ast.Call(
- name=f"toInterval{self.interval_name.capitalize()}",
+ name=interval_spec(self.interval_name).interval_func,
args=[ast.Constant(value=self.interval_count)],
)
def number_interval_periods_hogql(self) -> ast.Expr:
+ interval_func = interval_spec(self.interval_name).interval_func
if self.interval_count == 1:
return ast.Call(
- name=f"toInterval{self.interval_name.capitalize()}",
+ name=interval_func,
args=[ast.Field(chain=["number"])],
)
else:
return ast.Call(
- name=f"toInterval{self.interval_name.capitalize()}",
+ name=interval_func,
args=[
ast.Call(
name="multiply", args=[ast.Field(chain=["number"]), ast.Constant(value=self.interval_count)]
@@ -389,16 +357,6 @@ class QueryDateRange:
}
-PERIOD_MAP: dict[str, timedelta | relativedelta] = {
- "second": timedelta(seconds=1),
- "minute": timedelta(minutes=1),
- "hour": timedelta(hours=1),
- "day": timedelta(days=1),
- "week": timedelta(weeks=1),
- "month": relativedelta(months=1),
-}
-
-
class QueryDateRangeWithIntervals(QueryDateRange):
"""
Only used in retention queries where we need to figure out date_from
@@ -468,7 +426,7 @@ class QueryDateRangeWithIntervals(QueryDateRange):
return date_to
def get_start_of_interval_hogql(self, *, source: ast.Expr | None = None) -> ast.Expr:
- trunc_func = get_trunc_func_ch(self.interval_type.name.lower())
+ trunc_func = get_trunc_func(self.interval_type)
trunc_func_args: list[ast.Expr] = [source] if source else [ast.Constant(value=self.date_from())]
if trunc_func == "toStartOfWeek":
trunc_func_args.append(
@@ -478,18 +436,4 @@ class QueryDateRangeWithIntervals(QueryDateRange):
def date_to_start_of_interval(date: datetime, interval: IntervalType, team: Team) -> datetime:
- match interval:
- case IntervalType.HOUR:
- return date.replace(minute=0, second=0, microsecond=0)
- case IntervalType.DAY:
- return date.replace(hour=0, minute=0, second=0, microsecond=0)
- case IntervalType.WEEK:
- week_start_alignment_days = date.isoweekday() % 7
- if team.week_start_day == WeekStartDay.MONDAY:
- week_start_alignment_days = date.weekday()
-
- return (date - timedelta(days=week_start_alignment_days)).replace(hour=0, minute=0, second=0, microsecond=0)
- case IntervalType.MONTH:
- return date.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
- case _:
- raise ValueError(f"Unsupported interval {interval}")
+ return interval_spec(interval).align(date, team.week_start_day)
diff --git a/posthog/interval_specs.py b/posthog/interval_specs.py
new file mode 100644
index 000000000000..6f6a11984dab
--- /dev/null
+++ b/posthog/interval_specs.py
@@ -0,0 +1,151 @@
+from collections.abc import Callable
+from dataclasses import dataclass
+from datetime import datetime, timedelta
+from typing import Literal, Optional, Union, cast
+
+from dateutil.relativedelta import relativedelta
+
+from posthog.schema_enums import IntervalType
+
+IntervalLiteral = Literal["second", "minute", "hour", "day", "week", "month"]
+
+
+class UnsupportedIntervalError(ValueError):
+ pass
+
+
+def _align_second(date: datetime, week_start_day: Optional[int]) -> datetime:
+ return date.replace(microsecond=0)
+
+
+def _align_minute(date: datetime, week_start_day: Optional[int]) -> datetime:
+ return date.replace(second=0, microsecond=0)
+
+
+def _align_hour(date: datetime, week_start_day: Optional[int]) -> datetime:
+ return date.replace(minute=0, second=0, microsecond=0)
+
+
+def _align_day(date: datetime, week_start_day: Optional[int]) -> datetime:
+ return date.replace(hour=0, minute=0, second=0, microsecond=0)
+
+
+def _align_week(date: datetime, week_start_day: Optional[int]) -> datetime:
+ date = _align_day(date, week_start_day)
+ if week_start_day == 1: # WeekStartDay.MONDAY
+ alignment_days = date.weekday()
+ else:
+ alignment_days = date.isoweekday() % 7
+ return date - timedelta(days=alignment_days)
+
+
+def _align_month(date: datetime, week_start_day: Optional[int]) -> datetime:
+ return date.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
+
+
+@dataclass(frozen=True)
+class IntervalSpec:
+ """Everything the query layer knows about one interval size — adding an interval means adding one entry to INTERVAL_SPECS."""
+
+ interval_type: IntervalType
+ # ClickHouse toStartOf* function, None when ClickHouse has no DateTime-compatible one
+ trunc_func: Optional[str]
+ interval_func: str
+ relativedelta_kwarg: str
+ period: Union[timedelta, relativedelta]
+ align: Callable[[datetime, Optional[int]], datetime]
+ staleness_default: Optional[timedelta]
+ staleness_lazy: Optional[timedelta]
+
+
+# Ordered smallest to largest — ORDERED_INTERVALS derives interval comparison from this order
+INTERVAL_SPECS: dict[IntervalLiteral, IntervalSpec] = {
+ "second": IntervalSpec(
+ interval_type=IntervalType.SECOND,
+ trunc_func=None, # toStartOfSecond only supports DateTime64
+ interval_func="toIntervalSecond",
+ relativedelta_kwarg="seconds",
+ period=timedelta(seconds=1),
+ align=_align_second,
+ staleness_default=None,
+ staleness_lazy=None,
+ ),
+ "minute": IntervalSpec(
+ interval_type=IntervalType.MINUTE,
+ trunc_func="toStartOfMinute",
+ interval_func="toIntervalMinute",
+ relativedelta_kwarg="minutes",
+ period=timedelta(minutes=1),
+ align=_align_minute,
+ staleness_default=timedelta(minutes=5),
+ staleness_lazy=timedelta(minutes=15),
+ ),
+ "hour": IntervalSpec(
+ interval_type=IntervalType.HOUR,
+ trunc_func="toStartOfHour",
+ interval_func="toIntervalHour",
+ relativedelta_kwarg="hours",
+ period=timedelta(hours=1),
+ align=_align_hour,
+ staleness_default=timedelta(hours=1),
+ staleness_lazy=timedelta(hours=2),
+ ),
+ "day": IntervalSpec(
+ interval_type=IntervalType.DAY,
+ trunc_func="toStartOfDay",
+ interval_func="toIntervalDay",
+ relativedelta_kwarg="days",
+ period=timedelta(days=1),
+ align=_align_day,
+ staleness_default=timedelta(hours=6),
+ staleness_lazy=timedelta(hours=12),
+ ),
+ "week": IntervalSpec(
+ interval_type=IntervalType.WEEK,
+ trunc_func="toStartOfWeek",
+ interval_func="toIntervalWeek",
+ relativedelta_kwarg="weeks",
+ period=timedelta(weeks=1),
+ align=_align_week,
+ staleness_default=timedelta(days=1),
+ staleness_lazy=timedelta(days=1),
+ ),
+ "month": IntervalSpec(
+ interval_type=IntervalType.MONTH,
+ trunc_func="toStartOfMonth",
+ interval_func="toIntervalMonth",
+ relativedelta_kwarg="months",
+ period=relativedelta(months=1),
+ align=_align_month,
+ staleness_default=timedelta(days=1),
+ staleness_lazy=timedelta(days=1),
+ ),
+}
+
+ORDERED_INTERVALS: list[IntervalType] = [spec.interval_type for spec in INTERVAL_SPECS.values()]
+
+PERIOD_MAP: dict[str, Union[timedelta, relativedelta]] = {name: spec.period for name, spec in INTERVAL_SPECS.items()}
+
+
+def interval_spec(interval: Union[IntervalType, str, None]) -> IntervalSpec:
+ if interval is None:
+ key = "day"
+ elif isinstance(interval, IntervalType):
+ key = interval.value
+ else:
+ key = interval.lower()
+ spec = INTERVAL_SPECS.get(cast(IntervalLiteral, key))
+ if spec is None:
+ raise UnsupportedIntervalError(f"Interval {interval!r} is unsupported")
+ return spec
+
+
+def get_trunc_func(interval: Union[IntervalType, str, None]) -> str:
+ spec = interval_spec(interval)
+ if spec.trunc_func is None:
+ raise UnsupportedIntervalError(f"Interval {spec.interval_type} has no ClickHouse truncation function")
+ return spec.trunc_func
+
+
+def get_interval_func(interval: Union[IntervalType, str, None]) -> str:
+ return interval_spec(interval).interval_func
diff --git a/posthog/queries/util.py b/posthog/queries/util.py
index a66fa274d128..62c3e853224b 100644
--- a/posthog/queries/util.py
+++ b/posthog/queries/util.py
@@ -6,6 +6,7 @@ from zoneinfo import ZoneInfo
from rest_framework.exceptions import ValidationError
+from posthog.interval_specs import UnsupportedIntervalError, get_interval_func, get_trunc_func
from posthog.models.team.team import Team, WeekStartDay
from posthog.schema_enums import PersonsOnEventsMode
@@ -54,20 +55,6 @@ TIME_IN_SECONDS: dict[str, Any] = {
"month": 3600 * 24 * 30, # TODO: Let's get rid of this lie! Months are not all 30 days long
}
-PERIOD_TO_TRUNC_FUNC: dict[str, str] = {
- "hour": "toStartOfHour",
- "week": "toStartOfWeek",
- "day": "toStartOfDay",
- "month": "toStartOfMonth",
-}
-
-PERIOD_TO_INTERVAL_FUNC: dict[str, str] = {
- "hour": "toIntervalHour",
- "week": "toIntervalWeek",
- "day": "toIntervalDay",
- "month": "toIntervalMonth",
-}
-
# TODO: refactor since this is only used in one spot now
def format_ch_timestamp(timestamp: datetime, convert_to_timezone: Optional[str] = None):
@@ -102,21 +89,17 @@ def get_start_of_interval_sql(
def get_trunc_func_ch(period: Optional[str]) -> str:
- if period is None:
- period = "day"
- ch_function = PERIOD_TO_TRUNC_FUNC.get(period.lower())
- if ch_function is None:
+ try:
+ return get_trunc_func(period)
+ except UnsupportedIntervalError:
raise ValidationError(f"Period {period} is unsupported.")
- return ch_function
def get_interval_func_ch(period: Optional[str]) -> str:
- if period is None:
- period = "day"
- ch_function = PERIOD_TO_INTERVAL_FUNC.get(period.lower())
- if ch_function is None:
+ try:
+ return get_interval_func(period)
+ except UnsupportedIntervalError:
raise ValidationError(f"Interval {period} is unsupported.")
- return ch_function
def get_time_in_seconds_for_period(period: Optional[str]) -> str:
diff --git a/posthog/test/test_interval_specs.py b/posthog/test/test_interval_specs.py
new file mode 100644
index 000000000000..99ccf6897bb2
--- /dev/null
+++ b/posthog/test/test_interval_specs.py
@@ -0,0 +1,18 @@
+from unittest import TestCase
+
+from parameterized import parameterized
+
+from posthog.schema import IntervalType
+
+from posthog.interval_specs import UnsupportedIntervalError, interval_spec
+
+
+class TestIntervalSpecs(TestCase):
+ @parameterized.expand([(interval,) for interval in IntervalType])
+ def test_every_interval_type_has_a_spec(self, interval: IntervalType):
+ spec = interval_spec(interval)
+ self.assertEqual(spec.interval_type, interval)
+
+ def test_unknown_interval_raises_instead_of_falling_back(self):
+ with self.assertRaises(UnsupportedIntervalError):
+ interval_spec("fortnight")
diff --git a/posthog/test/test_utils.py b/posthog/test/test_utils.py
index 540a7d6f33bf..801777c5660a 100644
--- a/posthog/test/test_utils.py
+++ b/posthog/test/test_utils.py
@@ -383,6 +383,32 @@ class TestRelativeDateParse(TestCase):
"2019-11-30",
)
+ @parameterized.expand(
+ [
+ ("minus_one", "-1q", "2019-10-31"),
+ ("minus_two", "-2q", "2019-07-31"),
+ ("current_start", "qStart", "2020-01-01"),
+ ("current_end", "qEnd", "2020-03-31"),
+ ("minus_one_start", "-1qStart", "2019-10-01"),
+ ("minus_two_start", "-2qStart", "2019-07-01"),
+ ("minus_one_end", "-1qEnd", "2019-12-31"),
+ ("minus_two_end", "-2qEnd", "2019-09-30"),
+ ]
+ )
+ @freeze_time("2020-01-31")
+ def test_quarter(self, _name, input, expected_date):
+ self.assertEqual(
+ relative_date_parse(input, ZoneInfo("UTC")).strftime("%Y-%m-%d"),
+ expected_date,
+ )
+
+ @freeze_time("2020-01-31")
+ def test_quarter_human_friendly_comparison_periods_keeps_week_alignment(self):
+ self.assertEqual(
+ relative_date_parse("-1q", ZoneInfo("UTC"), human_friendly_comparison_periods=True).strftime("%Y-%m-%d"),
+ "2019-11-01",
+ )
+
@freeze_time("2020-01-31")
def test_year(self):
self.assertEqual(
diff --git a/posthog/utils.py b/posthog/utils.py
index 7f0d8a0928db..10b82703e889 100644
--- a/posthog/utils.py
+++ b/posthog/utils.py
@@ -247,6 +247,15 @@ def relative_date_parse_with_delta_mapping(
else:
parsed_dt -= relativedelta(**delta_mapping) # type: ignore
+ if match_group_dict["kind"] == "q":
+ # Quarter boundaries depend on the resulting month, so they can't be expressed
+ # as a static delta mapping like mStart/yStart — snap after applying the delta
+ quarter_start_month = ((parsed_dt.month - 1) // 3) * 3 + 1
+ if match_group_dict["position"] == "Start":
+ parsed_dt += relativedelta(month=quarter_start_month, day=1)
+ elif match_group_dict["position"] == "End":
+ parsed_dt += relativedelta(month=quarter_start_month + 2, day=31)
+
if always_truncate:
# Truncate to the start of the hour for hour-precision datetimes, to the start of the day for larger intervals
# TODO: Remove this from this function, this should not be the responsibility of it
@@ -329,7 +338,11 @@ def get_delta_mapping_for(
delta_mapping["seconds"] = int(number)
elif kind == "q":
if number:
- delta_mapping["weeks"] = 13 * int(number)
+ if human_friendly_comparison_periods:
+ # 13 whole weeks keeps weekdays aligned when comparing to the previous quarter
+ delta_mapping["weeks"] = 13 * int(number)
+ else:
+ delta_mapping["months"] = 3 * int(number)
elif kind == "y":
if number:
if human_friendly_comparison_periods:
diff --git a/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.py b/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.py
index 82749b9dd876..1dd7b0e4a2f8 100644
--- a/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.py
+++ b/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.py
@@ -482,13 +482,6 @@ class StickinessQueryRunner(AnalyticsQueryRunner[StickinessQueryResponse]):
action = Action.objects.get(pk=int(series.id), team__project_id=self.team.project_id)
return action.name
- def intervals_num(self) -> int:
- delta = self.query_date_range.date_to() - self.query_date_range.date_from()
- if self.query_date_range.interval_name == "day":
- return delta.days + 1
- else:
- return delta.days
-
def setup_series(self) -> list[SeriesWithExtras]:
series_with_extras = [
SeriesWithExtras(