From 147c48a5718e9c96a58230268fd307d0af02140d Mon Sep 17 00:00:00 2001 From: antzucaro Date: Sat, 17 Aug 2013 00:34:33 -0400 Subject: [PATCH] Damn off-by-one errors. *shakes fist* --- queries/show_elo_rot.sql | 4 ++-- scripts/update_elos.sql | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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; -- 2.39.2