fix hr display error when not download completed

This commit is contained in:
xiaomlove
2023-09-21 03:23:40 +08:00
parent 36aa10f64f
commit ab517bf412
4 changed files with 9 additions and 5 deletions

View File

@@ -62,6 +62,10 @@ class HitAndRun extends NexusModel
if ($this->status != self::STATUS_INSPECTING) {
return '---';
}
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');

View File

@@ -236,7 +236,7 @@ class HitAndRunRepository extends BaseRepository
'added' => Carbon::now()->toDateTimeString(),
'subject' => nexus_trans('hr.reached_message_subject', ['hit_and_run_id' => $hitAndRun->id], $hitAndRun->user->locale),
'msg' => nexus_trans('hr.reached_message_content', [
'completed_at' => $hitAndRun->snatch->completedat->toDateTimeString(),
'completed_at' => format_datetime($hitAndRun->snatch->completedat),
'torrent_id' => $hitAndRun->torrent_id,
'torrent_name' => $hitAndRun->torrent->name,
], $hitAndRun->user->locale),
@@ -335,7 +335,7 @@ class HitAndRunRepository extends BaseRepository
'added' => Carbon::now()->toDateTimeString(),
'subject' => nexus_trans('hr.unreached_message_subject', ['hit_and_run_id' => $hitAndRun->id], $hitAndRun->user->locale),
'msg' => nexus_trans('hr.unreached_message_content', [
'completed_at' => $hitAndRun->snatch->completedat->toDateTimeString(),
'completed_at' => format_datetime($hitAndRun->snatch->completedat),
'torrent_id' => $hitAndRun->torrent_id,
'torrent_name' => $hitAndRun->torrent->name,
], $hitAndRun->user->locale),

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.7');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-09-20');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-09-21');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -630,9 +630,9 @@ if ($az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS && !$isDonor
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'));
$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 {
do_log("$hrLog, total downloaded: {$snatchInfo['downloaded']} <= required: $requiredDownloaded", "debug");
do_log("$hrLog, total downloaded: {$snatchInfo['downloaded']} < required: $requiredDownloaded", "debug");
}
} else {
do_log("$hrLog, already exists", "debug");