From fe1b54842d9fb385f872c534cd586af446df9250 Mon Sep 17 00:00:00 2001 From: Christopher Charbonneau Wells Date: Sat, 9 Sep 2017 11:20:37 -0400 Subject: [PATCH] Correct sleep graph duration displays for entries crossing midnight. --- reports/graphs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reports/graphs.py b/reports/graphs.py index 27e888d9..294c9d65 100644 --- a/reports/graphs.py +++ b/reports/graphs.py @@ -59,7 +59,7 @@ def diaperchange_types(child): def sleep_times(child): - """Create a graph showing blocked out period of sleep during each day.""" + """Create a graph showing blocked out periods of sleep during each day.""" instances = Sleep.objects.filter(child=child).order_by('start') y_df = pd.DataFrame() text_df = pd.DataFrame() @@ -83,9 +83,9 @@ def sleep_times(child): text_df, df_index, adjustment['column'], - adjustment['duration'], + adjustment['duration'].seconds/60, 'Asleep {} ({} to {})'.format( - duration_string(duration), + duration_string(adjustment['duration']), adjustment['start_time'].strftime('%I:%M %p'), adjustment['end_time'].strftime('%I:%M %p') ) @@ -100,7 +100,7 @@ def sleep_times(child): 'column': end_time.date().isoformat(), 'start_time': adj_start_time, 'end_time': end_time, - 'duration': (end_time - adj_start_time).seconds/60 + 'duration': end_time - adj_start_time } # Adjust end_time for the current entry.