Skip to content

Commit

Permalink
Damn off-by-one errors. *shakes fist*
Browse files Browse the repository at this point in the history
  • Loading branch information
antzucaro committed Aug 17, 2013
1 parent 0a9d4c5 commit 147c48a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions queries/show_elo_rot.sql
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion 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;

0 comments on commit 147c48a

Please sign in to comment.