Made refreshing more guaranteed

This commit is contained in:
Jacob Henry 2018-12-02 12:34:16 -05:00
parent 297773ea12
commit c5231f1ef0
2 changed files with 23 additions and 9 deletions

View File

@ -258,7 +258,8 @@ def export_points(headers: List[str], points: List[PointStatus]) -> None:
def apply_house_points(points: List[PointStatus], assigns: List[Optional[JobAssignment]]):
"""
Modifies the points list to reflect job assignment scores.
Destroys existing values in the column
Destroys existing values in the column.
Should be called each time we re-export, for validations sake.
"""
# First, eliminate all house points
for p in points:

View File

@ -252,7 +252,14 @@ async def reset_callback(slack: SlackClient, msg: dict, match: Match) -> None:
"""
Resets the scores.
"""
# Get curr rows
# Unassign everything
assigns = await house_management.import_assignments()
for a in assigns:
if a is not None:
a.signer = None
await house_management.export_assignments(assigns)
# Now wipe points
headers, points = house_management.import_points()
# Set to 0/default
@ -260,18 +267,19 @@ async def reset_callback(slack: SlackClient, msg: dict, match: Match) -> None:
new = house_management.PointStatus(brother=points[i].brother)
points[i] = new
house_management.apply_house_points(points, await house_management.import_assignments())
house_management.export_points(headers, points)
# Now unsign everything
assigns = await house_management.import_assignments()
for a in assigns:
if a is not None:
a.signer = None
await house_management.export_assignments(assigns)
slack_util.reply(slack, msg, "Reset scores and signoffs")
async def refresh_callback(slack: SlackClient, msg: dict, match: Match) -> None:
headers, points = await house_management.import_points()
house_management.apply_house_points(points, await house_management.import_assignments())
house_management.export_points(headers, points)
slack_util.reply(slack, msg, "Force updated point values")
async def nag_callback(slack, msg, match):
# Get the day
day = match.group(1).lower().strip()
@ -344,3 +352,8 @@ nag_hook = slack_util.Hook(nag_callback,
reassign_hook = slack_util.Hook(reassign_callback,
patterns=r"reassign\s+(.*?)->\s+(.+)",
channel_whitelist=[channel_util.HOUSEJOBS])
refresh_hook = slack_util.Hook(refresh_callback,
patterns="refresh points",
channel_whitelist=[channel_util.COMMAND_CENTER_ID]
)