// Get waiting peers due to maxslot queue for this torrent - July 30, 2022
function checkSlotWait(int $torrent_id)
{
global $db;
$waiting = $db->query_params("SELECT (SELECT COUNT(DISTINCT torrent_id) FROM peers WHERE user_id = p.user_id AND seeder = 'no') AS total_active, u.slots, u.username, u.avatar_thumb, p.torrent_id, p.seeder FROM peers p LEFT JOIN users u ON u.user_id = p.user_id WHERE u.user_id = p.user_id AND p.seeder = 'no' AND p.torrent_id = :torrent_id", array(
'torrent_id' => $torrent_id
));
foreach ($waiting->fetchAll() as $checkslotwait) {
if (intval($checkslotwait['total_active']) > intval($checkslotwait['slots'])) {
printf('<div>Peer waiting: <img style="vertical-align:middle;margin-left:7px;width:15px;height:15px" alt="%s" src="/%s"></div>', html_escape($checkslotwait['username']), $checkslotwait['avatar_thumb']);
}
}
}
checkSlotWait($row['torrent_id']);
Last edited by STorrents2020 on 2022-07-31 00:04:25