From fcfe2358ceace0ed990d551c73bf5e627a1755c9 Mon Sep 17 00:00:00 2001 From: Alexander Metzger Date: Sat, 10 Feb 2024 16:55:07 -0800 Subject: [PATCH] default statspage to last 15 days in daily view --- recipes/VideoBotsStats.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/recipes/VideoBotsStats.py b/recipes/VideoBotsStats.py index e7fea6c12..a8fd4e541 100644 --- a/recipes/VideoBotsStats.py +++ b/recipes/VideoBotsStats.py @@ -291,15 +291,16 @@ def render_date_view_inputs(self, bi): start_date = bi.created_at end_date = timezone.now() else: - start_of_year_date = timezone.now().replace(month=1, day=1) + fifteen_days_ago = timezone.now() - timedelta(days=15) + fifteen_days_ago = fifteen_days_ago.replace(hour=0, minute=0, second=0) st.session_state.setdefault( "start_date", self.request.query_params.get( - "start_date", start_of_year_date.strftime("%Y-%m-%d") + "start_date", fifteen_days_ago.strftime("%Y-%m-%d") ), ) start_date: datetime = ( - st.date_input("Start date", key="start_date") or start_of_year_date + st.date_input("Start date", key="start_date") or fifteen_days_ago ) st.session_state.setdefault( "end_date", @@ -311,7 +312,7 @@ def render_date_view_inputs(self, bi): st.date_input("End date", key="end_date") or timezone.now() ) st.session_state.setdefault( - "view", self.request.query_params.get("view", "Weekly") + "view", self.request.query_params.get("view", "Daily") ) st.write("---") view = st.horizontal_radio(