diff --git a/app/Repositories/AttendanceRepository.php b/app/Repositories/AttendanceRepository.php index 7c75acc6..51790209 100644 --- a/app/Repositories/AttendanceRepository.php +++ b/app/Repositories/AttendanceRepository.php @@ -98,9 +98,11 @@ class AttendanceRepository extends BaseRepository $size = 10000; $caseWhens = []; $idArr = []; + $table = 'attendance'; while (true) { $logPrefix = "[MIGRATE_ATTENDANCE], page: $page, size: $size"; - $result = Attendance::query() + //as soon as possible, don't use eloquent + $result = NexusDB::table($table) ->groupBy(['uid']) ->selectRaw('uid, max(id) as id, count(*) as counts') ->forPage($page, $size) @@ -111,13 +113,8 @@ class AttendanceRepository extends BaseRepository break; } foreach ($result as $row) { - //use case when instead. $caseWhens[] = sprintf('when %s then %s', $row->id, $row->counts); $idArr[] = $row->id; -// $update = [ -// 'total_days' => $row->counts, -// ]; -// $updateResult = $row->update($update); do_log(sprintf( "$logPrefix, update user: %s(ID: %s) => %s", $row->uid, $row->id, $row->counts @@ -130,7 +127,7 @@ class AttendanceRepository extends BaseRepository return 0; } $caseWhenStr = sprintf('case id %s end', implode(' ', $caseWhens)); - $result = Attendance::query() + $result = NexusDB::table($table) ->whereIn('id', $idArr) ->update(['total_days' => NexusDB::raw($caseWhenStr)]); diff --git a/public/index.php b/public/index.php index 6c78e4b8..4f900b27 100644 --- a/public/index.php +++ b/public/index.php @@ -174,7 +174,7 @@ if ($showlastxforumposts_main == "yes" && $CURUSER) // ------------- start: latest torrents ------------------// if ($showlastxtorrents_main == "yes") { - $result = sql_query("SELECT * FROM torrents where visible='yes' ORDER BY added DESC LIMIT 5") or sqlerr(__FILE__, __LINE__); + $result = sql_query("SELECT id,name,leechers,seeders FROM torrents where visible='yes' ORDER BY id DESC LIMIT 5") or sqlerr(__FILE__, __LINE__); if(mysql_num_rows($result) != 0 ) { print ("