Theoretically better handling of unassigned or N/A jobs
This commit is contained in:
parent
4d94d7586b
commit
a15ae0fd11
|
|
@ -46,7 +46,7 @@ class JobAssignment(object):
|
|||
Tracks a job's assignment and completion
|
||||
"""
|
||||
job: Job
|
||||
assignee: scroll_util.Brother
|
||||
assignee: Optional[scroll_util.Brother]
|
||||
signer: Optional[scroll_util.Brother]
|
||||
late: bool
|
||||
bonus: bool
|
||||
|
|
@ -152,11 +152,14 @@ async def import_assignments() -> List[Optional[JobAssignment]]:
|
|||
|
||||
# Now make an assignment for the job
|
||||
# Find the brother it is assigned to
|
||||
if assignee is not None and assignee != "" and assignee != "N/A":
|
||||
try:
|
||||
assignee = await scroll_util.find_by_name(assignee, SHEET_LOOKUP_THRESHOLD)
|
||||
except scroll_util.BrotherNotFound:
|
||||
# If we can't get one close enough, make a dummy
|
||||
assignee = scroll_util.Brother(assignee, scroll_util.MISSINGBRO_SCROLL)
|
||||
else:
|
||||
assignee = None
|
||||
|
||||
# Find the brother who is currently listed as having signed it off
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ async def signoff_callback(slack: SlackClient, msg: dict, match: Match) -> None:
|
|||
|
||||
# Score by name similarity, only accepting non-assigned jobs
|
||||
def scorer(assign: house_management.JobAssignment):
|
||||
if assign.assignee is not None:
|
||||
r = fuzz.ratio(signee.name, assign.assignee.name)
|
||||
if assign.signer is None and r > MIN_RATIO:
|
||||
return r
|
||||
|
|
@ -187,6 +188,7 @@ async def late_callback(slack: SlackClient, msg: dict, match: Match) -> None:
|
|||
|
||||
# Score by name similarity. Don't care if signed off or not
|
||||
def scorer(assign: house_management.JobAssignment):
|
||||
if assign.assignee is not None:
|
||||
r = fuzz.ratio(signee.name, assign.assignee.name)
|
||||
if r > MIN_RATIO:
|
||||
return r
|
||||
|
|
@ -218,6 +220,7 @@ async def reassign_callback(slack: SlackClient, msg: dict, match: Match) -> None
|
|||
# Score by name similarity to the first brother. Don't care if signed off or not,
|
||||
# as we want to be able to transfer even after signoffs (why not, amirite?)
|
||||
def scorer(assign: house_management.JobAssignment):
|
||||
if assign.assignee is not None:
|
||||
r = fuzz.ratio(from_bro.name, assign.assignee.name)
|
||||
if r > MIN_RATIO:
|
||||
return r
|
||||
|
|
@ -291,6 +294,8 @@ async def nag_callback(slack, msg, match):
|
|||
response = "Do yer jerbs! They are as follows:\n"
|
||||
for assign in assigns:
|
||||
# Make the row template
|
||||
if assign.assignee is None:
|
||||
continue
|
||||
response += "({}) {} -- {} ".format(assign.job.house, assign.job.name, assign.assignee.name)
|
||||
|
||||
# Find the people to @
|
||||
|
|
|
|||
Loading…
Reference in New Issue