Skip to content

Commit

Permalink
default statspage to last 15 days in daily view
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi authored and devxpy committed Feb 14, 2024
1 parent 23f9e73 commit caf6227
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions recipes/VideoBotsStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand Down

0 comments on commit caf6227

Please sign in to comment.