From 45c41047dac16253c2e694c849f106855ff69de5 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Fri, 16 May 2025 14:19:06 +0700 Subject: [PATCH] improve claim settle message --- app/Console/Commands/ClaimSettle.php | 4 +-- app/Console/Commands/Test.php | 1 + app/Repositories/ClaimRepository.php | 39 +++++++++++++++++++--------- nexus/Torrent/Torrent.php | 6 ----- resources/lang/en/claim.php | 1 + resources/lang/zh_CN/claim.php | 1 + resources/lang/zh_TW/claim.php | 1 + 7 files changed, 33 insertions(+), 20 deletions(-) diff --git a/app/Console/Commands/ClaimSettle.php b/app/Console/Commands/ClaimSettle.php index 529095d8..1e293854 100644 --- a/app/Console/Commands/ClaimSettle.php +++ b/app/Console/Commands/ClaimSettle.php @@ -40,8 +40,8 @@ class ClaimSettle extends Command { $rep = new ClaimRepository(); $uid = $this->option('uid'); - $force = $this->option('force'); - $test = $this->option('test'); + $force = $this->option('force') ?? false; + $test = $this->option('test') ?? false; $this->info(sprintf('uid: %s, force: %s, test: %s', $uid, $force, $test)); if (!$uid) { $result = $rep->settleCronjob(); diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 666f740c..5f8228ad 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -9,6 +9,7 @@ use App\Models\PersonalAccessToken; use App\Models\Torrent; use App\Models\TorrentExtra; use App\Models\User; +use App\Repositories\ClaimRepository; use App\Repositories\ExamRepository; use App\Repositories\SeedBoxRepository; use App\Repositories\UploadRepository; diff --git a/app/Repositories/ClaimRepository.php b/app/Repositories/ClaimRepository.php index 953b821b..ff19b7ca 100644 --- a/app/Repositories/ClaimRepository.php +++ b/app/Repositories/ClaimRepository.php @@ -311,10 +311,16 @@ class ClaimRepository extends BaseRepository $msg[] = nexus_trans('claim.claim_total', [ 'total' => count($allTorrentIdArr)], $locale); //列表数据只取部分展示 - $reachList = collect(array_slice($reachedTorrentIdArr, 0, self::SETTLE_MSG_SLICE_COUNT))->map( - fn($item) => sprintf("[url=details.php?id=%s]%s[/url]", $item, $torrentInfo->get($item)->name) - )->implode("\n"); - $msg[] = nexus_trans("claim.claim_reached_counts", ['counts' => count($reachedTorrentIdArr)], $locale) . "\n$reachList"; + $sliceCount = self::SETTLE_MSG_SLICE_COUNT; + $sliceTip = "... (" . nexus_trans('claim.slice_tip', ['slice_count' => $sliceCount], $locale) . ")"; + $reachPart = nexus_trans("claim.claim_reached_counts", ['counts' => count($reachedTorrentIdArr), 'slice_count' => $sliceCount], $locale); + if (!empty($reachedTorrentIdArr)) { + $reachList = collect(array_slice($reachedTorrentIdArr, 0, $sliceCount))->map( + fn($item) => sprintf("[url=details.php?id=%s]%s[/url]", $item, $torrentInfo->get($item)->name) + )->implode("\n"); + $reachPart .= sprintf("\n%s\n%s", $reachList, $sliceTip); + } + $msg[] = $reachPart; $msg[] = nexus_trans( "claim.claim_reached_summary", [ 'bonus_per_hour' => number_format($bonusResult['seed_bonus'], 2), @@ -323,15 +329,24 @@ class ClaimRepository extends BaseRepository ], $locale ); - $remainList = collect(array_slice($remainTorrentIdArr, 0, self::SETTLE_MSG_SLICE_COUNT))->map( - fn($item) => sprintf("[url=details.php?id=%s]%s[/url]", $item, $torrentInfo->get($item)->name) - )->implode("\n"); - $msg[] = nexus_trans("claim.claim_unreached_remain_counts", ['counts' => count($remainTorrentIdArr)], $locale) . "\n$remainList"; + $remainPart = nexus_trans("claim.claim_unreached_remain_counts", ['counts' => count($remainTorrentIdArr), 'slice_count' => $sliceCount], $locale); + if (!empty($remainTorrentIdArr)) { + $remainList = collect(array_slice($remainTorrentIdArr, 0, $sliceCount))->map( + fn($item) => sprintf("[url=details.php?id=%s]%s[/url]", $item, $torrentInfo->get($item)->name) + )->implode("\n"); + $remainPart .= sprintf("\n%s\n%s", $remainList, $sliceTip); + } + $msg[] = $remainPart; + + $removePart = nexus_trans("claim.claim_unreached_remove_counts", ['counts' => count($unReachedTorrentIdArr), 'slice_count' => $sliceCount], $locale); + if (!empty($unReachedTorrentIdArr)) { + $unReachList = collect(array_slice($unReachedTorrentIdArr, 0, $sliceCount))->map( + fn($item) => sprintf("[url=details.php?id=%s]%s[/url]", $item, $torrentInfo->get($item)->name) + )->implode("\n"); + $removePart .= sprintf("\n%s\n%s", $unReachList, $sliceTip); + } + $msg[] = $removePart; - $unReachList = collect(array_slice($unReachedTorrentIdArr, 0, self::SETTLE_MSG_SLICE_COUNT))->map( - fn($item) => sprintf("[url=details.php?id=%s]%s[/url]", $item, $torrentInfo->get($item)->name) - )->implode("\n"); - $msg[] = nexus_trans("claim.claim_unreached_remove_counts", ['counts' => count($unReachedTorrentIdArr)], $locale) . "\n$unReachList"; if ($deductTotal) { $msg[] = nexus_trans( "claim.claim_unreached_summary", [ diff --git a/nexus/Torrent/Torrent.php b/nexus/Torrent/Torrent.php index dcc61c57..893f601e 100644 --- a/nexus/Torrent/Torrent.php +++ b/nexus/Torrent/Torrent.php @@ -56,12 +56,6 @@ class Torrent return $snatchedList; } - public function listPTGenInfo(array $torrentIdArr) - { - $list = TorrentExtra::query()->whereIn('torrent_id', $torrentIdArr)->get(['torrent_id', 'pt_gen']); - } - - public function renderProgressBar($activeStatus, $progress): string { $color = '#aaa'; diff --git a/resources/lang/en/claim.php b/resources/lang/en/claim.php index 1d3b0b0a..752f3a0b 100644 --- a/resources/lang/en/claim.php +++ b/resources/lang/en/claim.php @@ -23,6 +23,7 @@ return [ 'claim_unreached_remain_counts' => 'Unreached torrent remain counts: [b]:counts[/b]', 'claim_unreached_remove_counts' => 'Unreached torrent remove counts: [b]:counts[/b]', 'claim_unreached_summary' => 'Deduct bonus every unreached torrent:[b]:deduct_per_torrent[/b], total deduct: [b]:deduct_total[/b]', + 'slice_tip' => 'Show only the first :slice_count items', 'confirm_give_up' => 'Are you sure you want to give up claiming this torrent?', 'add_claim' => 'Claim', diff --git a/resources/lang/zh_CN/claim.php b/resources/lang/zh_CN/claim.php index 65895ff0..1e2d7109 100644 --- a/resources/lang/zh_CN/claim.php +++ b/resources/lang/zh_CN/claim.php @@ -23,6 +23,7 @@ return [ 'claim_unreached_remain_counts' => '未达标保留数:[b]:counts[/b]', 'claim_unreached_remove_counts' => '未达标删除数:[b]:counts[/b]', 'claim_unreached_summary' => '未达标每个种子扣除魔力:[b]:deduct_per_torrent[/b],总扣除魔力:[b]:deduct_total[/b]', + 'slice_tip' => '只显示前 :slice_count 个', 'confirm_give_up' => '确定要放弃认领此种子吗?', 'add_claim' => '认领', diff --git a/resources/lang/zh_TW/claim.php b/resources/lang/zh_TW/claim.php index 1375767f..007905e2 100644 --- a/resources/lang/zh_TW/claim.php +++ b/resources/lang/zh_TW/claim.php @@ -22,6 +22,7 @@ return [ 'claim_unreached_remain_counts' => '未達標保留數:[b]:counts[/b]', 'claim_unreached_remove_counts' => '未達標刪除數:[b]:counts[/b]', 'claim_unreached_summary' => '未達標每個種子扣除魔力:[b]:deduct_per_torrent[/b],總扣除魔力:[b]:deduct_total[/b]', + 'slice_tip' => '只顯示前 :slice_count 個', 'confirm_give_up' => '確定要放棄認領此種子嗎?', 'add_claim' => '認領',