From 762cdb2daebd03696c70c699a5a64287fb05f510 Mon Sep 17 00:00:00 2001 From: lgb <353856593@qq.com> Date: Thu, 21 Sep 2023 12:32:51 +0800 Subject: [PATCH 1/2] hr only for leecher --- public/announce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/announce.php b/public/announce.php index a2029e7e7..37b228968 100644 --- a/public/announce.php +++ b/public/announce.php @@ -607,7 +607,7 @@ } //handle hr -if ($az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS && !$isDonor && isset($torrent['mode'])) { +if (($left > 0 || $event == "completed") && $az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS && !$isDonor && isset($torrent['mode'])) { $hrMode = \App\Models\HitAndRun::getConfig('mode', $torrent['mode']); $hrLog = sprintf("[HR_LOG] user: %d, torrent: %d, hrMode: %s", $userid, $torrentid, $hrMode); if ($hrMode == \App\Models\HitAndRun::MODE_GLOBAL || ($hrMode == \App\Models\HitAndRun::MODE_MANUAL && $torrent['hr'] == \App\Models\Torrent::HR_YES)) { From 6895fb4a6a64e67ee63dfe3385ff305aef84c25c Mon Sep 17 00:00:00 2001 From: lgb <353856593@qq.com> Date: Thu, 21 Sep 2023 13:26:06 +0800 Subject: [PATCH 2/2] hr inspect time use create_time --- app/Models/HitAndRun.php | 11 ++++++----- public/announce.php | 6 +++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Models/HitAndRun.php b/app/Models/HitAndRun.php index e0b76d41c..0fb43ba8f 100644 --- a/app/Models/HitAndRun.php +++ b/app/Models/HitAndRun.php @@ -62,17 +62,18 @@ private function doGetInspectTimeLeft(): string if ($this->status != self::STATUS_INSPECTING) { return '---'; } - if (!$this->snatch->completedat) { - //not download completed - return '---'; - } + //change to use create time +// if (!$this->snatch->completedat) { +// //not download completed +// return '---'; +// } $searchBoxId = $this->torrent->basic_category->mode ?? 0; if ($searchBoxId == 0) { do_log(sprintf('[INVALID_CATEGORY], Torrent: %s', $this->torrent_id), 'error'); return '---'; } $inspectTime = HitAndRun::getConfig('inspect_time', $searchBoxId); - $diffInSeconds = Carbon::now()->diffInSeconds($this->snatch->completedat->addHours($inspectTime)); + $diffInSeconds = Carbon::now()->diffInSeconds($this->created_at->addHours($inspectTime)); return mkprettytime($diffInSeconds); } diff --git a/public/announce.php b/public/announce.php index 37b228968..b73f9c333 100644 --- a/public/announce.php +++ b/public/announce.php @@ -628,7 +628,11 @@ $snatchInfo = get_snatch_info($torrentid, $userid); $requiredDownloaded = $torrent['size'] * $includeRate; if ($snatchInfo['downloaded'] >= $requiredDownloaded) { - $sql = "insert into hit_and_runs (uid, torrent_id, snatched_id) values ($userid, $torrentid, {$snatchInfo['id']}) on duplicate key update updated_at = " . sqlesc(date('Y-m-d H:i:s')); + $nowStr = date('Y-m-d H:i:s'); + $sql = sprintf( + "insert into hit_and_runs (uid, torrent_id, snatched_id, created_at, updated_at) values (%d, %d, %d, '%s', '%s') on duplicate key update created_at = '%s', updated_at = '%s'", + $userid, $torrentid, $snatchInfo['id'], $nowStr, $nowStr, $nowStr, $nowStr + ); $affectedRows = sql_query($sql); do_log("$hrLog, total downloaded: {$snatchInfo['downloaded']} >= required: $requiredDownloaded, [INSERT_H&R], sql: $sql, affectedRows: $affectedRows"); } else {