From c018870ecda8133a30e2c23438a59e28de34a3ea Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Mon, 10 Feb 2014 18:32:54 -0500 Subject: [PATCH] Playing one Elo game type in the past 30 days will prevent rot. --- scripts/update_elos.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/update_elos.sql b/scripts/update_elos.sql index f724e03..bda0ae2 100644 --- a/scripts/update_elos.sql +++ b/scripts/update_elos.sql @@ -1,6 +1,12 @@ begin; - update player_elos + update player_elos pe set elo=greatest(100, elo - ((current_date - (update_dt::date)-31)/7+1)) where update_dt < (current_timestamp at time zone 'UTC' - interval '30 days') + and not exists ( + select 1 + from player_elos + where player_id = pe.player_id + and update_dt >= (current_timestamp at time zone 'UTC' - interval '30 days') + ) and elo != 100; end; -- 2.39.2