Skip to content

Commit efb635c

Browse files
committed
fix h&R detail
1 parent e48932d commit efb635c

File tree

3 files changed

+67
-7
lines changed

3 files changed

+67
-7
lines changed

app/Filament/Resources/User/HitAndRunResource.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
use App\Filament\Resources\User\HitAndRunResource\Pages;
66
use App\Filament\Resources\User\HitAndRunResource\RelationManagers;
77
use App\Models\HitAndRun;
8+
use App\Models\User;
89
use App\Repositories\HitAndRunRepository;
910
use Filament\Forms;
1011
use Filament\Forms\Form;
12+
use Filament\Infolists\Infolist;
1113
use Filament\Resources\Resource;
1214
use Filament\Tables\Table;
1315
use Filament\Tables;
@@ -16,6 +18,8 @@
1618
use Illuminate\Support\Collection;
1719
use Illuminate\Support\Facades\Auth;
1820
use Illuminate\Support\HtmlString;
21+
use Filament\Infolists\Components;
22+
use Filament\Infolists;
1923

2024
class HitAndRunResource extends Resource
2125
{
@@ -87,6 +91,51 @@ public static function table(Table $table): Table
8791
]);
8892
}
8993

94+
public static function infolist(Infolist $infolist): Infolist
95+
{
96+
return $infolist
97+
->schema([
98+
Infolists\Components\TextEntry::make('id'),
99+
Infolists\Components\TextEntry::make('statusText')
100+
->label(__("label.status"))
101+
,
102+
Infolists\Components\TextEntry::make('uid')
103+
->formatStateUsing(fn ($record) => username_for_admin($record->uid))
104+
->label(__("label.username"))
105+
,
106+
Infolists\Components\TextEntry::make('torrent_id')
107+
->formatStateUsing(fn ($record) => $record->torrent->name)
108+
->label(__("label.torrent.label"))
109+
,
110+
Infolists\Components\TextEntry::make('snatch.uploadedText')
111+
->label(__("label.uploaded"))
112+
,
113+
Infolists\Components\TextEntry::make('snatch.downloadedText')
114+
->label(__("label.downloaded"))
115+
,
116+
Infolists\Components\TextEntry::make('snatch.shareRatio')
117+
->label(__("label.ratio"))
118+
,
119+
Infolists\Components\TextEntry::make('seedTimeRequired')
120+
->label(__("label.seed_time_required"))
121+
,
122+
Infolists\Components\TextEntry::make('inspectTimeLeft')
123+
->label(__("label.inspect_time_left"))
124+
,
125+
Infolists\Components\TextEntry::make('comment')
126+
->formatStateUsing(fn ($record) => nl2br($record->comment))
127+
->label(__("label.comment"))
128+
,
129+
Infolists\Components\TextEntry::make('created_at')
130+
->label(__("label.created_at"))
131+
,
132+
Infolists\Components\TextEntry::make('updated_at')
133+
->label(__("label.updated_at"))
134+
,
135+
])->columns(4);
136+
137+
}
138+
90139
public static function getEloquentQuery(): Builder
91140
{
92141
return parent::getEloquentQuery()->with(['user', 'torrent', 'snatch', 'torrent.basic_category']);

app/Filament/Resources/User/HitAndRunResource/Pages/ViewHitAndRun.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ViewHitAndRun extends ViewRecord
1414
{
1515
protected static string $resource = HitAndRunResource::class;
1616

17-
protected static string $view = 'filament.detail-card';
17+
// protected static string $view = 'filament.detail-card';
1818

1919
private function getDetailCardData(): array
2020
{

app/Repositories/ExamRepository.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use App\Models\Torrent;
1212
use App\Models\User;
1313
use App\Models\UserBanLog;
14+
use App\Models\UserModifyLog;
1415
use Carbon\Carbon;
1516
use Illuminate\Database\Eloquent\Builder;
1617
use Illuminate\Support\Arr;
@@ -1137,9 +1138,10 @@ public function cronjobCheckout($ignoreTimeRange = false): int
11371138
}
11381139
$result += $examUsers->count();
11391140
$now = Carbon::now()->toDateTimeString();
1140-
$examUserIdArr = $uidToDisable = $messageToSend = $userBanLog = $userModcommentUpdate = [];
1141+
$examUserIdArr = $uidToDisable = $messageToSend = $userBanLog = [];
11411142
$bonusLog = $userBonusUpdate = $uidToUpdateBonus = [];
11421143
$examUserToInsert = [];
1144+
$userModifyLogs = [];
11431145
foreach ($examUsers as $examUser) {
11441146
$minId = $examUser->id;
11451147
$examUserIdArr[] = $examUser->id;
@@ -1200,8 +1202,14 @@ public function cronjobCheckout($ignoreTimeRange = false): int
12001202
'begin' => $examUser->begin,
12011203
'end' => $examUser->end
12021204
], $locale);
1203-
$userModcomment = sprintf('%s - %s', date('Y-m-d'), $userModcomment);
1204-
$userModcommentUpdate[] = sprintf("when `id` = %s then concat_ws('\n', '%s', modcomment)", $uid, $userModcomment);
1205+
// $userModcomment = sprintf('%s - %s', date('Y-m-d'), $userModcomment);
1206+
// $userModcommentUpdate[] = sprintf("when `id` = %s then concat_ws('\n', '%s', modcomment)", $uid, $userModcomment);
1207+
$userModifyLogs[] = [
1208+
'user_id' => $uid,
1209+
'content' => $userModcomment,
1210+
'created_at' => $now,
1211+
'updated_at' => $now,
1212+
];
12051213
$banLogReason = nexus_trans('exam.ban_log_reason', [
12061214
'exam_name' => $exam->name,
12071215
'begin' => $examUser->begin,
@@ -1242,7 +1250,7 @@ public function cronjobCheckout($ignoreTimeRange = false): int
12421250
'msg' => $msg
12431251
];
12441252
}
1245-
DB::transaction(function () use ($uidToDisable, $messageToSend, $examUserIdArr, $examUserToInsert, $userBanLog, $userModcommentUpdate, $userBonusUpdate, $bonusLog, $uidToUpdateBonus, $userTable, $logPrefix) {
1253+
DB::transaction(function () use ($uidToDisable, $messageToSend, $examUserIdArr, $examUserToInsert, $userBanLog, $userModifyLogs, $userBonusUpdate, $bonusLog, $uidToUpdateBonus, $userTable, $logPrefix) {
12461254
ExamUser::query()->whereIn('id', $examUserIdArr)->update(['status' => ExamUser::STATUS_FINISHED]);
12471255
do {
12481256
$deleted = ExamProgress::query()->whereIn('exam_user_id', $examUserIdArr)->limit(10000)->delete();
@@ -1252,8 +1260,8 @@ public function cronjobCheckout($ignoreTimeRange = false): int
12521260
if (!empty($uidToDisable)) {
12531261
$uidStr = implode(', ', $uidToDisable);
12541262
$sql = sprintf(
1255-
"update %s set enabled = '%s', modcomment = case %s end where id in (%s)",
1256-
$userTable, User::ENABLED_NO, implode(' ', $userModcommentUpdate), $uidStr
1263+
"update %s set enabled = '%s' where id in (%s)",
1264+
$userTable, User::ENABLED_NO, $uidStr
12571265
);
12581266
$updateResult = DB::update($sql);
12591267
do_log(sprintf("$logPrefix, disable %s users: %s, sql: %s, updateResult: %s", count($uidToDisable), $uidStr, $sql, $updateResult));
@@ -1276,6 +1284,9 @@ public function cronjobCheckout($ignoreTimeRange = false): int
12761284
if (!empty($bonusLog)) {
12771285
BonusLogs::query()->insert($bonusLog);
12781286
}
1287+
if (!empty($userModifyLogs)) {
1288+
UserModifyLog::query()->insert($userModifyLogs);
1289+
}
12791290
});
12801291
}
12811292
return $result;

0 commit comments

Comments
 (0)