From cd7de04e6cb24d45cc55c1a51e07ece01a2c9b71 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Thu, 12 May 2022 01:35:01 +0800 Subject: [PATCH] fix hr pager & format uploaded/downloaded change value --- app/Repositories/UserRepository.php | 12 +++++++----- public/myhr.php | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 4e64d6ae..d6e6ae42 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -224,9 +224,11 @@ class UserRepository extends BaseRepository $targetUser = User::query()->findOrFail($uid, User::$commonFields); $old = $targetUser->{$sourceField}; $valueAtomic = $value; + $formatSize = false; if (in_array($field, ['uploaded', 'downloaded'])) { //Frontend unit: GB $valueAtomic = $value * 1024 * 1024 * 1024; + $formatSize = true; } if ($action == 'Increment') { $new = $old + abs($valueAtomic); @@ -239,12 +241,12 @@ class UserRepository extends BaseRepository $modCommentText = nexus_trans('message.field_value_change_message_body', [ 'field' => nexus_trans("user.labels.$sourceField", [], 'en'), 'operator' => $operator->username, - 'old' => $old, - 'new' => $new, + 'old' => $formatSize ? mksize($old) : $old, + 'new' => $formatSize ? mksize($new) : $new, 'reason' => $reason, ], 'en'); $modCommentText = date('Y-m-d') . " - $modCommentText"; - do_log("user: $uid, $modCommentText"); + do_log("user: $uid, $modCommentText", 'alert'); $update = [ $sourceField => $new, 'modcomment' => NexusDB::raw("if(modcomment = '', '$modCommentText', concat_ws('\n', '$modCommentText', modcomment))"), @@ -255,8 +257,8 @@ class UserRepository extends BaseRepository $msg = nexus_trans('message.field_value_change_message_body', [ 'field' => $fieldLabel, 'operator' => $operator->username, - 'old' => $old, - 'new' => $new, + 'old' => $formatSize ? mksize($old) : $old, + 'new' => $formatSize ? mksize($new) : $new, 'reason' => $reason, ], $locale); $message = [ diff --git a/public/myhr.php b/public/myhr.php index 3effb07d..51aaaa22 100644 --- a/public/myhr.php +++ b/public/myhr.php @@ -40,7 +40,7 @@ print $filterForm; $baseQuery = \App\Models\HitAndRun::query()->where('uid', $userid)->where('status', $status); $rescount = (clone $baseQuery)->count(); -list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $rescount, "?status=$status"); +list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $rescount, "?status=$status&"); print(""); print("
{$lang_myhr['th_hr_id']}