From c4541b6d5b6027abe5e43e7b04cbabe96048bcbd Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Fri, 12 Aug 2022 14:06:25 +0100 Subject: [PATCH] refactor the get_lunch_mins and get_coffee_mins --- cara/apps/calculator/model_generator.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index f7a73ea2..9f9dbce3 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -213,14 +213,16 @@ class FormData: start <= lunch_finish <= finish) def get_lunch_mins(population): + lunch_mins = 0 if getattr(self, f'{population}_lunch_option'): - return getattr(self, f'{population}_lunch_finish') - getattr(self, f'{population}_lunch_start') - return 0 + lunch_mins = getattr(self, f'{population}_lunch_finish') - getattr(self, f'{population}_lunch_start') + return lunch_mins def get_coffee_mins(population): + coffee_mins = 0 if getattr(self, f'{population}_coffee_break_option') != 'coffee_break_0': - return COFFEE_OPTIONS_INT[getattr(self, f'{population}_coffee_break_option')] * getattr(self, f'{population}_coffee_duration') - return 0 + coffee_mins = COFFEE_OPTIONS_INT[getattr(self, f'{population}_coffee_break_option')] * getattr(self, f'{population}_coffee_duration') + return coffee_mins def get_activity_mins(population): return getattr(self, f'{population}_finish') - getattr(self, f'{population}_start')