calculate seed bonus when specific torrent id do not join peers

This commit is contained in:
xiaomlove
2022-05-06 18:18:36 +08:00
parent 585e2ccfc3
commit cc7b046926
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -5588,14 +5588,15 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
$A = 0;
$count = $torrent_peer_count = 0;
$logPrefix = "[CALCULATE_SEED_BONUS], uid: $uid, torrentIdArr: " . json_encode($torrentIdArr);
$whereTorrent = '';
if ($torrentIdArr !== null) {
if (empty($torrentIdArr)) {
$torrentIdArr = [-1];
}
$whereTorrent = sprintf("and peers.torrent in (%s)", implode(',', $torrentIdArr));
$idStr = implode(',', \Illuminate\Support\Arr::wrap($torrentIdArr));
$sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, 'NO_PEER_ID' as peerID from torrents WHERE id in ($idStr)";
} else {
$sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, peers.id as peerID from torrents LEFT JOIN peers ON peers.torrent = torrents.id WHERE peers.userid = $uid AND peers.seeder ='yes' group by peers.torrent, peers.peer_id";
}
$sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, peers.id as peerID from torrents LEFT JOIN peers ON peers.torrent = torrents.id WHERE peers.userid = $uid AND peers.seeder ='yes' $whereTorrent group by peers.torrent, peers.peer_id";
$torrentResult = \Nexus\Database\NexusDB::select($sql);
do_log("$logPrefix, sql: $sql, count: " . count($torrentResult));
foreach ($torrentResult as $torrent)
+1 -1
View File
@@ -134,7 +134,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST'){
<tr><td class="rowhead"><?php echo $lang_complains['text_new_email']?></td><td class="rowfollow" align="left"><input type="email" name="email" style="width: 180px; border: 1px solid gray" /></td></tr>
<tr><td class="rowhead"><?php echo $lang_complains['text_new_body']?></td><td class="rowfollow" align="left"><textarea name="body" style="width: 200px; height: 250px" placeholder="<?= $lang_complains['text_new_body_placeholder'] ?>"></textarea></td></tr>
<?php show_image_code (); ?>
<tr><td class="toolbox" colspan="2" align="right"><input type="submit" value="<?= $lang_complains['text_new_submit']?>" class="btn" /></td></tr>
<tr><td class="toolbox" colspan="2" align="center"><input type="submit" value="<?= $lang_complains['text_new_submit']?>" class="btn" /></td></tr>
</table>
</form>
<?php