syxolk / euro2024

Euro 2024: Betting with your friends
https://www.wetten2024.de
51 stars 22 forks source link

Highscore Rank Arrows not working correctly #66

Closed syxolk closed 6 years ago

syxolk commented 6 years ago

The highscore rank arrows are supposed to show for each user the number of rank places lost/gained in the last 24 hours before the last match. To do that, the current highscore rank is compared with the past highscore rank. However, that's currently not computed correctly:

https://github.com/syxolk/euro2016/blob/master/migrations/20180526210753-mat-view-highscore.js

rank() over (order by 
  coalesce(bets.score, 0) desc,
  coalesce(count3, 0) desc,
  coalesce(count2, 0) desc,
  coalesce(count1, 0) desc,
  coalesce(count0, 0) desc) as "rank",
rank() over (order by
  coalesce(bets_past.score, 0) desc,
  coalesce(count3, 0) desc,
  coalesce(count2, 0) desc,
  coalesce(count1, 0) desc,
  coalesce(count0, 0) desc) as "rank_past"

It uses the current count0/1/2/3 instead of the past ones for rank_past.