From d47d5c4a76d854f861b9c65e26b1e3555fb3e6fd Mon Sep 17 00:00:00 2001 From: overflowerror Date: Sat, 3 Aug 2024 20:36:55 +0200 Subject: [PATCH] fix: expectation calculation was wrong --- migrations/0001_mobsMatchesAndRating.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/migrations/0001_mobsMatchesAndRating.sql b/migrations/0001_mobsMatchesAndRating.sql index cfee350..cfa2ef0 100644 --- a/migrations/0001_mobsMatchesAndRating.sql +++ b/migrations/0001_mobsMatchesAndRating.sql @@ -97,13 +97,13 @@ WITH RECURSIVE ratings_history (ratings, last_update) AS ( CASE WHEN winner = 1 THEN 1 ELSE 0 - END::numeric - expectation + END::numeric - expectation_for_mob1 ) AS mob1rating, mob2rating + 32::numeric * ( CASE WHEN winner = 2 THEN 1 ELSE 0 - END::numeric - expectation + END::numeric - (1 - expectation_for_mob1) ) AS mob2rating FROM ( @@ -118,9 +118,9 @@ WITH RECURSIVE ratings_history (ratings, last_update) AS ( (1::numeric / (1::numeric + power( 10::numeric, - (mob1rating - mob2rating) / 400::numeric + (mob2rating - mob1rating) / 400::numeric )) - ) AS expectation + ) AS expectation_for_mob1 FROM ( SELECT @@ -174,8 +174,8 @@ FROM jsonb_each( CREATE VIEW mm_rating_trends (mob, rating, "date", id) AS SELECT - key AS mob, - value AS rating, + cast(key AS numeric) AS mob, + cast(value AS numeric) rating, "date", id FROM (