fix(datastore): include morning-ending night sleep in dashboard, pass data-dir, and auto git-sync on writes
This commit is contained in:
@@ -151,7 +151,10 @@ def generate_dashboard_html(engine: DatastoreEngine) -> str:
|
||||
CASE WHEN is_open THEN NULL ELSE strftime(local_end, '%H:%M') END AS end_fmt,
|
||||
sleep_type, location, note, duration_minutes, is_open
|
||||
FROM v_sleep
|
||||
WHERE subject = 'mila' AND log_date = '{today_str}'
|
||||
WHERE subject = 'mila' AND (
|
||||
log_date = '{today_str}'
|
||||
OR (sleep_type = 'night' AND CAST(local_end AS DATE) = '{today_str}')
|
||||
)
|
||||
ORDER BY start ASC
|
||||
"""
|
||||
).fetchall()
|
||||
@@ -173,12 +176,21 @@ def generate_dashboard_html(engine: DatastoreEngine) -> str:
|
||||
"""
|
||||
).fetchone()
|
||||
|
||||
today_tot_hours = f"{today_agg[0]:.2f} h" if today_agg and today_agg[0] else "0 h"
|
||||
today_night_min = today_agg[2] if today_agg else 0
|
||||
# Prefer the completed night sleep that ended this morning/today for the top card
|
||||
morning_night = next((s for s in today_nights if not s[7] and s[6] is not None), None)
|
||||
if morning_night and morning_night[6]:
|
||||
today_night_min = morning_night[6]
|
||||
else:
|
||||
today_night_min = today_agg[2] if today_agg else 0
|
||||
|
||||
today_nap_count = today_agg[1] if today_agg else len(today_naps)
|
||||
today_nap_min = sum(n[6] or 0 for n in today_naps)
|
||||
|
||||
today_tot_min = today_night_min + today_nap_min
|
||||
today_tot_hours = f"{today_tot_min / 60.0:.2f} h" if today_tot_min > 0 else "0 h"
|
||||
|
||||
today_night_h, today_night_m = divmod(today_night_min, 60)
|
||||
today_night_dur_str = f"{today_night_h} h {today_night_m:02d} min" if today_night_h > 0 else f"{today_night_m} min"
|
||||
today_nap_count = today_agg[1] if today_agg else 0
|
||||
today_nap_min = today_agg[3] if today_agg else 0
|
||||
|
||||
# 3. Today's Feedings (conditional)
|
||||
today_feedings = con.execute(
|
||||
|
||||
Reference in New Issue
Block a user