fix update torrent seeder&leecher count

This commit is contained in:
xiaomlove
2022-04-18 20:49:05 +08:00
parent fe98400dc0
commit 4b6850dba4

View File

@@ -735,15 +735,19 @@ class TrackerRepository extends BaseRepository
do_log("no event, return", 'debug');
return;
}
$torrent->seeders = Peer::query()
$seederResult = Peer::query()
->where('torrent', $torrent->id)
->where('to_go', '=',0)
->count();
->selectRaw("count(distinct(peer_id)) as counts")
->first();
$torrent->seeders = $seederResult ? $seederResult->counts : 0;
$torrent->leechers = Peer::query()
$leecherResult = Peer::query()
->where('torrent', $torrent->id)
->where('to_go', '>', 0)
->count();
->selectRaw("count(distinct(peer_id)) as counts")
->first();
$torrent->leechers = $leecherResult ? $leecherResult->counts : 0;
$torrent->visible = Torrent::VISIBLE_YES;
$torrent->last_action = Carbon::now();