From: antzucaro Date: Sat, 17 Aug 2013 04:34:33 +0000 (-0400) Subject: Damn off-by-one errors. *shakes fist* X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=147c48a5718e9c96a58230268fd307d0af02140d;p=xonotic%2Fxonstatdb.git Damn off-by-one errors. *shakes fist* --- diff --git a/queries/show_elo_rot.sql b/queries/show_elo_rot.sql index eccbe6d..33f415d 100644 --- a/queries/show_elo_rot.sql +++ b/queries/show_elo_rot.sql @@ -5,8 +5,8 @@ select update_dt last_update_dt, (current_date - (update_dt::date)) number_of_days, (current_date - (update_dt::date))-30 number_of_days_past_30, - (current_date - (update_dt::date)-31)/7 penalty, - greatest(100, elo - ((current_date - (update_dt::date)-31)/7)) new_elo + (current_date - (update_dt::date)-31)/7+1 penalty, + greatest(100, elo - ((current_date - (update_dt::date)-31)/7+1)) new_elo from player_elos where update_dt < (current_timestamp at time zone 'UTC' - interval '30 days') diff --git a/scripts/update_elos.sql b/scripts/update_elos.sql index 38d456d..f724e03 100644 --- a/scripts/update_elos.sql +++ b/scripts/update_elos.sql @@ -1,6 +1,6 @@ begin; update player_elos - set elo=greatest(100, elo - ((current_date - (update_dt::date)-31)/7)) + 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 elo != 100; end;