Skip to content

Commit

Permalink
Ladder: Add GXE filtering for ladders with a max elo above 1500
Browse files Browse the repository at this point in the history
  • Loading branch information
mia-pi-git committed Sep 5, 2024
1 parent d706436 commit 5512e76
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions lib/ntbb-ladder.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,32 @@ function getTop($prefix = null) {
"SELECT * FROM (SELECT * FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ? ORDER BY `elo` DESC LIMIT $overfetch) AS `unusedalias` WHERE `userid` LIKE ? LIMIT $limit",
[$this->formatid, "$prefix%"]
);
$res = $ladderdb->query(
"WITH `max_elo` AS (
SELECT MAX(elo) AS `max_elo` FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ?
),
`rpr_filtered` AS (
SELECT * FROM `{$ladderdb->prefix}ladder` WHERE
((SELECT `max_elo` FROM `max_elo`) <= 1500 OR `rprd` <= 100)
AND `formatid` = ?
)
SELECT * FROM
(SELECT * FROM `rpr_filtered` WHERE `formatid` = ? ORDER BY `elo` DESC LIMIT {$overfetch})
AS `unusedalias` WHERE `userid` LIKE ? LIMIT $limit",
[$this->formatid, $this->formatid, $this->formatid, "$prefix%"]
);
} else {
$res = $ladderdb->query(
"SELECT * FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ? ORDER BY `elo` DESC LIMIT $limit",
[$this->formatid]
"WITH max_elo AS (
SELECT MAX(elo) AS max_elo FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ?
),
rpr_filtered AS (
SELECT * FROM `{$ladderdb->prefix}ladder` WHERE
((SELECT `max_elo` FROM `max_elo`) <= 1500 OR `rprd` <= 100)
AND `formatid` = ?
)
SELECT * FROM `rpr_filtered` ORDER BY `elo` DESC LIMIT $limit",
[$this->formatid, $this->formatid]
);
}

Expand Down

0 comments on commit 5512e76

Please sign in to comment.