Merge remote-tracking branch 'refs/remotes/origin/php8' into php8

This commit is contained in:
xiaomlove
2023-09-22 01:19:51 +08:00
2 changed files with 12 additions and 7 deletions
+6 -5
View File
@@ -62,17 +62,18 @@ class HitAndRun extends NexusModel
if ($this->status != self::STATUS_INSPECTING) { if ($this->status != self::STATUS_INSPECTING) {
return '---'; return '---';
} }
if (!$this->snatch->completedat) { //change to use create time
//not download completed // if (!$this->snatch->completedat) {
return '---'; // //not download completed
} // return '---';
// }
$searchBoxId = $this->torrent->basic_category->mode ?? 0; $searchBoxId = $this->torrent->basic_category->mode ?? 0;
if ($searchBoxId == 0) { if ($searchBoxId == 0) {
do_log(sprintf('[INVALID_CATEGORY], Torrent: %s', $this->torrent_id), 'error'); do_log(sprintf('[INVALID_CATEGORY], Torrent: %s', $this->torrent_id), 'error');
return '---'; return '---';
} }
$inspectTime = HitAndRun::getConfig('inspect_time', $searchBoxId); $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); return mkprettytime($diffInSeconds);
} }
+6 -2
View File
@@ -607,7 +607,7 @@ else
} }
//handle hr //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']); $hrMode = \App\Models\HitAndRun::getConfig('mode', $torrent['mode']);
$hrLog = sprintf("[HR_LOG] user: %d, torrent: %d, hrMode: %s", $userid, $torrentid, $hrMode); $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)) { if ($hrMode == \App\Models\HitAndRun::MODE_GLOBAL || ($hrMode == \App\Models\HitAndRun::MODE_MANUAL && $torrent['hr'] == \App\Models\Torrent::HR_YES)) {
@@ -628,7 +628,11 @@ if ($az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS && !$isDonor
$snatchInfo = get_snatch_info($torrentid, $userid); $snatchInfo = get_snatch_info($torrentid, $userid);
$requiredDownloaded = $torrent['size'] * $includeRate; $requiredDownloaded = $torrent['size'] * $includeRate;
if ($snatchInfo['downloaded'] >= $requiredDownloaded) { 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); $affectedRows = sql_query($sql);
do_log("$hrLog, total downloaded: {$snatchInfo['downloaded']} >= required: $requiredDownloaded, [INSERT_H&R], sql: $sql, affectedRows: $affectedRows"); do_log("$hrLog, total downloaded: {$snatchInfo['downloaded']} >= required: $requiredDownloaded, [INSERT_H&R], sql: $sql, affectedRows: $affectedRows");
} else { } else {