I am trying to create this staffing grit to make my admin work easier at work. 'days' contains a week.
days = [M, T, W, Th, F]
days = [0, 1, 1, 1, 1] means s/he works everyday except for Mondays.
If the value is 2, that means they work a special shift.
S/he works from start_time to end_time - e.g. wakana works 0600-1400 everyday. S/he works from special_start to special_end on days the value is 2, e.g. eleonor works 0700-1900 Monday and Friday, and 0700-1500 on Wednesday.
I got Monday down, but I know there is a better way, perhaps using function, to print all days. I have been playing around forever with it now, but I cannot figure it out. Thank you in advance! I have so much respect for all of you experts!
staffing_data = [
{'name': 'wakana',
'start_time': 6,
'end_time': 14,
'days': [1, 1, 1, 1, 1],
'special_start': None,
'special_end': None},
{'name': 'kate',
'start_time': 11,
'end_time': 21,
'days': [0, 1, 1, 1, 1],
'special_start': None,
'special_end': None},
{'name': 'eleonor',
'start_time': 7,
'end_time': 19,
'days': [1, 0, 2, 0, 1],
'special_start': 7,
'special_end': 15}]
at_7 = 0
at_11 = 0
at_15 = 0
at_19 = 0
for person in staffing_data:
if person['start_time'] <= 7 and person['end_time'] > 7 and person['days'][0] == 1:
at_7 += 1
if person['start_time'] <= 11 and person['end_time'] > 11 and person['days'][0] == 1:
at_11 += 1
if person['start_time'] <= 15 and person['end_time'] > 15 and person['days'][0] == 1:
at_15 += 1
if person['start_time'] <= 19 and person['end_time'] > 19 and person['days'][0] == 1:
at_19 += 1
print(f"{at_7} at 7")
print(f"{at_11} at 11")
print(f"{at_15} at 15")
print(f"{at_19} at 19")
#Monday Staffing
#2 at 7
#3 at 11
#1 at 15
#0 at 19