Removed aforementioned delay, and instead just made it a batch job
This commit is contained in:
parent
208617db2f
commit
46129b8d24
|
|
@ -2,9 +2,8 @@ from fuzzywuzzy import process
|
||||||
|
|
||||||
import channel_util
|
import channel_util
|
||||||
import google_api
|
import google_api
|
||||||
import slack_util
|
|
||||||
import identifier
|
import identifier
|
||||||
import time
|
import slack_util
|
||||||
|
|
||||||
SHEET_ID = "1lPj9GjB00BuIq9GelOWh5GmiGsheLlowPnHLnWBvMOM"
|
SHEET_ID = "1lPj9GjB00BuIq9GelOWh5GmiGsheLlowPnHLnWBvMOM"
|
||||||
|
|
||||||
|
|
@ -14,6 +13,7 @@ output_range = "JobScoreTracker"
|
||||||
|
|
||||||
MIN_RATIO = 0.9
|
MIN_RATIO = 0.9
|
||||||
SIGNOFF_REWARD = 0.1
|
SIGNOFF_REWARD = 0.1
|
||||||
|
SAFETY_DELAY = 5
|
||||||
|
|
||||||
|
|
||||||
# Used to track a sufficiently shitty typed name
|
# Used to track a sufficiently shitty typed name
|
||||||
|
|
@ -64,9 +64,7 @@ def signoff_callback(slack, msg, match):
|
||||||
|
|
||||||
# Try giving the person a point
|
# Try giving the person a point
|
||||||
try:
|
try:
|
||||||
bro_name, bro_total = adjust_score(name, 1)
|
(bro_name, bro_total), (ass_name, ass_total) = adjust_scores((name, 1), (signer, SIGNOFF_REWARD))
|
||||||
time.sleep(1)
|
|
||||||
ass_name, ass_total = adjust_score(signer, SIGNOFF_REWARD)
|
|
||||||
slack_util.reply(slack, msg, "Gave {} one housejob point.\n"
|
slack_util.reply(slack, msg, "Gave {} one housejob point.\n"
|
||||||
"They now have {} for this period.\n"
|
"They now have {} for this period.\n"
|
||||||
"You ({}) were credited with the signoff".format(bro_name, bro_total, ass_name))
|
"You ({}) were credited with the signoff".format(bro_name, bro_total, ass_name))
|
||||||
|
|
@ -84,9 +82,7 @@ def punish_callback(slack, msg, match):
|
||||||
|
|
||||||
# Try giving the person a point
|
# Try giving the person a point
|
||||||
try:
|
try:
|
||||||
bro_name, bro_total = adjust_score(name, -1)
|
(bro_name, bro_total), (ass_name, ass_total) = adjust_scores((name, -1), (signer, -SIGNOFF_REWARD))
|
||||||
time.sleep(1)
|
|
||||||
ass_name, ass_total = adjust_score(signer, -SIGNOFF_REWARD)
|
|
||||||
slack_util.reply(slack, msg, "Took one housejob point from {}.\n"
|
slack_util.reply(slack, msg, "Took one housejob point from {}.\n"
|
||||||
"They now have {} for this period.\n"
|
"They now have {} for this period.\n"
|
||||||
"Under the assumption that this was to undo a mistake, we have deducted the "
|
"Under the assumption that this was to undo a mistake, we have deducted the "
|
||||||
|
|
@ -99,34 +95,39 @@ def punish_callback(slack, msg, match):
|
||||||
slack_util.reply(slack, msg, e.as_response())
|
slack_util.reply(slack, msg, e.as_response())
|
||||||
|
|
||||||
|
|
||||||
def adjust_score(name, delta):
|
def adjust_scores(*name_delta_tuples):
|
||||||
# Get the current stuff
|
# Get the current stuff
|
||||||
points = get_curr_points()
|
points = get_curr_points()
|
||||||
names = [p[0] for p in points]
|
names = [p[0] for p in points]
|
||||||
|
results = []
|
||||||
|
|
||||||
# Find our guy
|
for name, delta in name_delta_tuples:
|
||||||
target_name, ratio = process.extractOne(name, names)
|
# Find our guy
|
||||||
ratio = ratio / 100.0
|
target_name, ratio = process.extractOne(name, names)
|
||||||
|
ratio = ratio / 100.0
|
||||||
|
|
||||||
# If bad ratio, error
|
# If bad ratio, error
|
||||||
if ratio < MIN_RATIO:
|
if ratio < MIN_RATIO:
|
||||||
raise BadName(target_name, ratio)
|
raise BadName(target_name, ratio)
|
||||||
|
|
||||||
# Where is he in the list?
|
# Where is he in the list?
|
||||||
target_index = names.index(target_name)
|
target_index = names.index(target_name)
|
||||||
|
|
||||||
# Get his current score
|
# Get his current score
|
||||||
curr_score = points[target_index][1]
|
curr_score = points[target_index][1]
|
||||||
|
|
||||||
# target should be in the form index, (name, score)
|
# target should be in the form index, (name, score)
|
||||||
target_new = [target_name, curr_score + delta]
|
target_new = [target_name, curr_score + delta]
|
||||||
|
results.append(target_new)
|
||||||
|
|
||||||
# Put it back
|
# Put it back
|
||||||
points[target_index] = target_new
|
points[target_index] = target_new
|
||||||
|
|
||||||
|
# Record all when done
|
||||||
put_points(points)
|
put_points(points)
|
||||||
|
|
||||||
# Return the adjusted name
|
# Return the adjusted name/score_tuples
|
||||||
return target_new
|
return results
|
||||||
|
|
||||||
|
|
||||||
def reset_callback(slack, msg, match):
|
def reset_callback(slack, msg, match):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue