Skip to content

Commit b85e3f5

Browse files
minor dashboard edits
1 parent 8746799 commit b85e3f5

File tree

1 file changed

+26
-33
lines changed

1 file changed

+26
-33
lines changed

Diff for: dashboard/app.py

+26-33
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@
4848
ui.input_date_range(
4949
"date_range",
5050
"Date range",
51-
start=(datetime.now() - timedelta(days=28)).strftime("%Y-%m-%d"),
52-
end=datetime.now().strftime("%Y-%m-%d"),
51+
start=(datetime.now() - timedelta(days=28)),
52+
end=datetime.now() + timedelta(days=1),
5353
)
5454
ui.input_action_button("last_7d", "Last 7 days")
5555
ui.input_action_button("last_14d", "Last 14 days")
5656
ui.input_action_button("last_28d", "Last 28 days")
5757
ui.input_action_button("last_91d", "Last 91 days")
5858
ui.input_action_button("last_182d", "Last 182 days")
5959
ui.input_action_button("last_365d", "Last 365 days")
60+
ui.input_action_button("last_730d", "Last 730 days")
6061
ui.input_action_button("last_all", "All available data")
6162

6263
with ui.value_box(full_screen=True):
@@ -65,7 +66,7 @@
6566
@render.express
6667
def total_days():
6768
start_date, end_date = date_range()
68-
days = (end_date - start_date).days
69+
days = (end_date - start_date).days - 1
6970
f"{days:,}"
7071

7172

@@ -335,64 +336,56 @@ def _downloads_data(downloads_t=downloads_t):
335336
return t
336337

337338

338-
@reactive.effect
339-
@reactive.event(input.last_7d)
340-
def _():
339+
def _update_date_range(days):
340+
start_date = datetime.now() - timedelta(days=days)
341+
end_date = datetime.now() + timedelta(days=1)
341342
ui.update_date_range(
342343
"date_range",
343-
start=(datetime.now() - timedelta(days=7)).strftime("%Y-%m-%d"),
344-
end=datetime.now().strftime("%Y-%m-%d"),
344+
start=start_date.strftime("%Y-%m-%d"),
345+
end=end_date.strftime("%Y-%m-%d"),
345346
)
346347

347348

349+
@reactive.effect
350+
@reactive.event(input.last_7d)
351+
def _():
352+
_update_date_range(days=7)
353+
354+
348355
@reactive.effect
349356
@reactive.event(input.last_14d)
350357
def _():
351-
ui.update_date_range(
352-
"date_range",
353-
start=(datetime.now() - timedelta(days=14)).strftime("%Y-%m-%d"),
354-
end=datetime.now().strftime("%Y-%m-%d"),
355-
)
358+
_update_date_range(days=14)
356359

357360

358361
@reactive.effect
359362
@reactive.event(input.last_28d)
360363
def _():
361-
ui.update_date_range(
362-
"date_range",
363-
start=(datetime.now() - timedelta(days=28)).strftime("%Y-%m-%d"),
364-
end=datetime.now().strftime("%Y-%m-%d"),
365-
)
364+
_update_date_range(days=28)
366365

367366

368367
@reactive.effect
369368
@reactive.event(input.last_91d)
370369
def _():
371-
ui.update_date_range(
372-
"date_range",
373-
start=(datetime.now() - timedelta(days=91)).strftime("%Y-%m-%d"),
374-
end=datetime.now().strftime("%Y-%m-%d"),
375-
)
370+
_update_date_range(days=91)
376371

377372

378373
@reactive.effect
379374
@reactive.event(input.last_182d)
380375
def _():
381-
ui.update_date_range(
382-
"date_range",
383-
start=(datetime.now() - timedelta(days=182)).strftime("%Y-%m-%d"),
384-
end=datetime.now().strftime("%Y-%m-%d"),
385-
)
376+
_update_date_range(days=182)
386377

387378

388379
@reactive.effect
389380
@reactive.event(input.last_365d)
390381
def _():
391-
ui.update_date_range(
392-
"date_range",
393-
start=(datetime.now() - timedelta(days=365)).strftime("%Y-%m-%d"),
394-
end=datetime.now().strftime("%Y-%m-%d"),
395-
)
382+
_update_date_range(days=365)
383+
384+
385+
@reactive.effect
386+
@reactive.event(input.last_730d)
387+
def _():
388+
_update_date_range(days=730)
396389

397390

398391
@reactive.effect

0 commit comments

Comments
 (0)