mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-20 17:37:23 +08:00
improve peer count update
This commit is contained in:
@@ -758,11 +758,12 @@ class TrackerRepository extends BaseRepository
|
||||
*
|
||||
* @param Torrent $torrent
|
||||
* @param $queries
|
||||
* @param Peer $peer
|
||||
* @param bool $isPeerExists
|
||||
*/
|
||||
private function updateTorrent(Torrent $torrent, $queries, bool $isPeerExists)
|
||||
{
|
||||
if (!empty($queries['event'])) {
|
||||
if (!empty($queries['event']) || !$isPeerExists) {
|
||||
$torrent->seeders = Peer::query()
|
||||
->where('torrent', $torrent->id)
|
||||
->where('to_go', '=',0)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.5');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-04-25');
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.6');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-04-27');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', true);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
+1
-1
@@ -1102,7 +1102,7 @@ if (!$Cache->get_page()){
|
||||
echo $Cache->next_row();
|
||||
|
||||
if ($tagKeyById->isNotEmpty()) {
|
||||
echo '<tr><td rowspan="3" class="embedded" style="padding-top: 4px">' . $tagRep->renderSpan($tagKeyById, $renderKeyArr, true) . '</td></tr>';
|
||||
echo '<tr><td colspan="3" class="embedded" style="padding-top: 4px">' . $tagRep->renderSpan($tagKeyById, $renderKeyArr, true) . '</td></tr>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+11
-1
@@ -93,6 +93,7 @@ function dltable($name, $arr, $torrent)
|
||||
}
|
||||
$downloaders = array();
|
||||
$seeders = array();
|
||||
$torrent = \App\Models\Torrent::query()->findOrFail($id, ['id', 'seeders', 'leechers']);
|
||||
$subres = sql_query("SELECT seeder, finishedat, downloadoffset, uploadoffset, ip, ipv4, ipv6, port, uploaded, downloaded, to_go, UNIX_TIMESTAMP(started) AS st, connectable, agent, peer_id, UNIX_TIMESTAMP(last_action) AS la, userid FROM peers WHERE torrent = $id") or sqlerr();
|
||||
while ($subrow = mysql_fetch_array($subres)) {
|
||||
if ($subrow["seeder"] == "yes")
|
||||
@@ -100,7 +101,16 @@ function dltable($name, $arr, $torrent)
|
||||
else
|
||||
$downloaders[] = $subrow;
|
||||
}
|
||||
|
||||
$seedersCount = count($seeders);
|
||||
$leechersCount = count($downloaders);
|
||||
if ($torrent->seeders != $seedersCount || $torrent->leechers != $leechersCount) {
|
||||
$update = [
|
||||
'seeders' => $seedersCount,
|
||||
'leechers' => $leechersCount,
|
||||
];
|
||||
$torrent->update($update);
|
||||
do_log("[UPDATE_TORRENT_SEEDERS_LEECHERS], torrent: $id, original: " . $torrent->toJson() . ", update: " . json_encode($update));
|
||||
}
|
||||
function leech_sort($a,$b) {
|
||||
$x = $a["to_go"];
|
||||
$y = $b["to_go"];
|
||||
|
||||
Reference in New Issue
Block a user