* Improve error message to include information from the exception * #347 Take short or long breaks from tray Correction: get_break() should not alter the break queue. * Fix incorrectly skipped long breaks
This commit is contained in:
parent
9a76aa4211
commit
201e6d2982
|
@ -132,6 +132,19 @@ class BreakQueue:
|
|||
shorts = self.__short_queue
|
||||
longs = self.__long_queue
|
||||
|
||||
# Reset break that has just ended
|
||||
if self.is_long_break():
|
||||
self.__current_break.time = self.__long_break_time
|
||||
if self.__current_long == 0 and self.__is_random_order:
|
||||
# Shuffle queue
|
||||
self.__build_longs()
|
||||
elif self.__current_break:
|
||||
# Reduce the break time from the next long break (default)
|
||||
if longs:
|
||||
longs[self.__current_long].time -= shorts[self.__current_short].time
|
||||
if self.__current_short == 0 and self.__is_random_order:
|
||||
self.__build_shorts()
|
||||
|
||||
if self.is_empty():
|
||||
return None
|
||||
|
||||
|
@ -144,11 +157,6 @@ class BreakQueue:
|
|||
else:
|
||||
break_obj = self.__next_short()
|
||||
|
||||
if self.__current_break is not None:
|
||||
# Reset the time of long breaks
|
||||
if self.__current_break.type == BreakType.LONG_BREAK:
|
||||
self.__current_break.time = self.__long_break_time
|
||||
|
||||
self.__current_break = break_obj
|
||||
self.context['session']['break'] = self.__current_break.name
|
||||
|
||||
|
@ -177,17 +185,10 @@ class BreakQueue:
|
|||
shorts = self.__short_queue
|
||||
break_obj = shorts[self.__current_short]
|
||||
self.context['break_type'] = 'short'
|
||||
# Reduce the break time from the next long break (default)
|
||||
if longs:
|
||||
longs[self.__current_long].time -= shorts[self.__current_short].time
|
||||
|
||||
# Update the index to next
|
||||
self.__current_short = (self.__current_short + 1) % len(shorts)
|
||||
|
||||
# Shuffle queue
|
||||
if self.__current_short == 0 and self.__is_random_order:
|
||||
self.__build_shorts()
|
||||
|
||||
return break_obj
|
||||
|
||||
def __next_long(self):
|
||||
|
@ -198,10 +199,6 @@ class BreakQueue:
|
|||
# Update the index to next
|
||||
self.__current_long = (self.__current_long + 1) % len(longs)
|
||||
|
||||
# Shuffle queue
|
||||
if self.__current_long == 0 and self.__is_random_order:
|
||||
self.__build_longs()
|
||||
|
||||
return break_obj
|
||||
|
||||
def __build_queue(self, break_type, break_configs, break_time, break_duration):
|
||||
|
|
Loading…
Reference in New Issue