Skip to content

Commit

Permalink
Update reason weight on next post after 7 days
Browse files Browse the repository at this point in the history
  • Loading branch information
𝐢𝐁𝐮𝐠 ♦ committed Sep 25, 2018
1 parent 0c3a3eb commit 2ae390e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion spamhandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ def should_whitelist_prevent_alert(user_url, reasons):
def sum_weight(reasons: list):
if not GlobalVars.reason_weights:
datahandling.update_reason_weights()
elif time.time() - GlobalVars.reason_weights['last_updated'] > 86400 * 7:
Tasks.do(datahandling.update_reason_weights)
s = 0
weights = GlobalVars.reason_weights
for r in reasons:
try:
s += GlobalVars.reason_weights[r]
s += weights[r]
except KeyError:
pass # s += 0
return s
Expand Down

0 comments on commit 2ae390e

Please sign in to comment.