|
1 | | -"""Activity Stats.""" |
| 1 | +"""Activity Statistics.""" |
2 | 2 |
|
3 | 3 | # ruff: noqa: PLR2004 |
4 | 4 | import datetime as dt |
|
15 | 15 | from helper_pandas import reorder_cols |
16 | 16 | from helper_ui_components import excel_download_buttons, list_sports, select_sport |
17 | 17 |
|
18 | | -st.title(__doc__[:-1]) # type: ignore |
19 | | -logger = get_logger_from_filename(__file__) |
| 18 | +LOGGER = get_logger_from_filename(__file__) |
20 | 19 |
|
21 | 20 |
|
22 | 21 | AGGREGATIONS = { |
@@ -254,6 +253,8 @@ def activity_stats_grouping( |
254 | 253 | time_unit = "yearmonth(date):T" |
255 | 254 | elif sel_freq == "Week": |
256 | 255 | time_unit = "date:T" |
| 256 | +else: |
| 257 | + time_unit = "date:T" |
257 | 258 |
|
258 | 259 | c = ( |
259 | 260 | alt.Chart( |
@@ -315,18 +316,15 @@ def get_cell(df: pd.DataFrame, sport: str, period: str, agg: str) -> float | int |
315 | 316 | for i in range(4): |
316 | 317 | col = cols[i] |
317 | 318 | sport = sports[i] |
| 319 | + prev1, prev2, prev3 = 0, 0, 0 |
318 | 320 | col.subheader(sport) |
319 | 321 | cur = get_cell(df=df2c, sport=sport, period=periods[0], agg=sel_agg) |
320 | 322 | if len(periods) >= 2: |
321 | 323 | prev1 = get_cell(df=df2c, sport=sport, period=periods[1], agg=sel_agg) |
322 | | - else: |
323 | | - prev1 = 0 |
324 | 324 | if len(periods) >= 3: |
325 | 325 | prev2 = get_cell(df=df2c, sport=sport, period=periods[2], agg=sel_agg) |
326 | 326 | if len(periods) >= 4: |
327 | 327 | prev3 = get_cell(df=df2c, sport=sport, period=periods[3], agg=sel_agg) |
328 | | - else: |
329 | | - prev3 = 0 |
330 | 328 | col.metric(label=periods[0], value=cur) |
331 | 329 | if len(periods) >= 2: |
332 | 330 | delta = round(prev1 - prev2, 1) if len(periods) >= 3 else None |
|
0 commit comments