mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
Merge remote-tracking branch 'refs/remotes/origin/php8' into php8
This commit is contained in:
@@ -17,6 +17,7 @@ use Illuminate\Support\Arr;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Nexus\Database\NexusDB;
|
||||||
|
|
||||||
class ExamRepository extends BaseRepository
|
class ExamRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
@@ -616,7 +617,7 @@ class ExamRepository extends BaseRepository
|
|||||||
$attributes['index'] = $index['index'];
|
$attributes['index'] = $index['index'];
|
||||||
$attributes['created_at'] = $now;
|
$attributes['created_at'] = $now;
|
||||||
$attributes['updated_at'] = $now;
|
$attributes['updated_at'] = $now;
|
||||||
$attributes['value'] = $this->getProgressValue($user, $index['index']);
|
$attributes['value'] = $this->getProgressValue($user, $index['index'], $examUser);
|
||||||
do_log("[GET_TOTAL_VALUE]: " . $attributes['value']);
|
do_log("[GET_TOTAL_VALUE]: " . $attributes['value']);
|
||||||
$newVersionProgress = ExamProgress::query()
|
$newVersionProgress = ExamProgress::query()
|
||||||
->where('exam_user_id', $examUser->id)
|
->where('exam_user_id', $examUser->id)
|
||||||
@@ -690,7 +691,7 @@ class ExamRepository extends BaseRepository
|
|||||||
return $examUser;
|
return $examUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getProgressValue(User $user, int $index)
|
private function getProgressValue(User $user, int $index, ExamUser $examUser)
|
||||||
{
|
{
|
||||||
if ($index == Exam::INDEX_UPLOADED) {
|
if ($index == Exam::INDEX_UPLOADED) {
|
||||||
return $user->uploaded;
|
return $user->uploaded;
|
||||||
@@ -708,7 +709,7 @@ class ExamRepository extends BaseRepository
|
|||||||
return $user->seed_points;
|
return $user->seed_points;
|
||||||
}
|
}
|
||||||
if ($index == Exam::INDEX_UPLOAD_TORRENT_COUNT) {
|
if ($index == Exam::INDEX_UPLOAD_TORRENT_COUNT) {
|
||||||
return Torrent::query()->where("owner", $user->id)->normal()->count();
|
return Torrent::query()->where("owner", $user->id)->where("added", ">=", $examUser->created_at)->normal()->count();
|
||||||
}
|
}
|
||||||
throw new \InvalidArgumentException("Invalid index: $index");
|
throw new \InvalidArgumentException("Invalid index: $index");
|
||||||
}
|
}
|
||||||
@@ -1302,4 +1303,32 @@ class ExamRepository extends BaseRepository
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fixIndexUploadTorrentCount()
|
||||||
|
{
|
||||||
|
$page = 1;
|
||||||
|
$size = 2000;
|
||||||
|
$examUserTable = (new ExamUser())->getTable();
|
||||||
|
$examProgressTable = (new ExamProgress())->getTable();
|
||||||
|
while (true) {
|
||||||
|
$offset = ($page - 1)*$size;
|
||||||
|
$list = NexusDB::table($examProgressTable)
|
||||||
|
->select("$examProgressTable.*, $examUserTable.created_at as exam_created_at")
|
||||||
|
->join($examUserTable, "$examProgressTable.exam_user_id", "=", "$examUserTable.id", "left")
|
||||||
|
->where("$examUserTable.status", ExamUser::STATUS_NORMAL)
|
||||||
|
->where("$examProgressTable.index", Exam::INDEX_UPLOAD_TORRENT_COUNT)
|
||||||
|
->limit($size)
|
||||||
|
->offset($offset)
|
||||||
|
->get()
|
||||||
|
;
|
||||||
|
if ($list->count() == 0) {
|
||||||
|
do_log("page: $page, offset: $offset, no more data...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach ($list as $item) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,6 +333,14 @@ class Update extends Install
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.8.13
|
||||||
|
*/
|
||||||
|
$settingName = "__has_fix_exam_index_UPLOAD_TORRENT_COUNT";
|
||||||
|
$hasFixExamIndexUploadTorrentCount = get_setting($settingName, false);
|
||||||
|
if (!$hasFixExamIndexUploadTorrentCount) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runExtraMigrate()
|
public function runExtraMigrate()
|
||||||
|
|||||||
Reference in New Issue
Block a user