Skip to content

Commit

Permalink
feat: removing duplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanJaeger committed Jun 27, 2024
1 parent e59ed2b commit 849c336
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions insights/widgets/usecases/get_source_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,6 @@ def apply_timezone_to_date_filters(default_filters: dict, timezone: str):
default_filters[key][subkey] = tz.localize(date_value)


def set_live_day(default_filters: dict):
start_of_day = datetime.combine(now().date(), time.min)
default_filters["created_on__gte"] = start_of_day


def apply_timezone_to_date_filters(default_filters: dict, timezone: str):
tz = pytz.timezone(timezone)
date_suffixes = ["__gte", "__lte"]

if default_filters.get("created_on__gte") == "now":
set_live_day(default_filters)

for key, value in default_filters.items():
if any(key.endswith(suffix) for suffix in date_suffixes):
if isinstance(value, str):
date_value = datetime.strptime(value, "%Y-%m-%d")
default_filters[key] = tz.localize(date_value)
elif isinstance(value, datetime):
default_filters[key] = tz.localize(value)


def get_source_data_from_widget(
widget: Widget, is_report: bool = False, filters: dict = {}, user_email: str = ""
):
Expand Down

0 comments on commit 849c336

Please sign in to comment.