mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
fix bugs
This commit is contained in:
@@ -167,10 +167,10 @@ class AttendanceRepository extends BaseRepository
|
||||
while (true) {
|
||||
$rows = $query->forPage($page, $size)->get();
|
||||
$log = "sql: " . last_query() . ", count: " . $rows->count();
|
||||
do_log($log, 'info', app()->runningInConsole());
|
||||
do_log($log, 'info', isRunningInConsole());
|
||||
if ($rows->isEmpty()) {
|
||||
$log = "no more data....";
|
||||
do_log($log, 'info', app()->runningInConsole());
|
||||
do_log($log, 'info', isRunningInConsole());
|
||||
break;
|
||||
}
|
||||
foreach ($rows as $row) {
|
||||
@@ -182,7 +182,7 @@ class AttendanceRepository extends BaseRepository
|
||||
->delete();
|
||||
$log = "delete: $deleted by sql: " . last_query();
|
||||
$deleteCounts += $deleted;
|
||||
do_log($log, 'info', app()->runningInConsole());
|
||||
do_log($log, 'info', isRunningInConsole());
|
||||
} while ($deleted > 0);
|
||||
}
|
||||
$page++;
|
||||
@@ -199,7 +199,7 @@ class AttendanceRepository extends BaseRepository
|
||||
public function migrateAttendanceLogs($uid = 0): int
|
||||
{
|
||||
$cleanUpCounts = $this->cleanup();
|
||||
do_log("cleanup count: $cleanUpCounts", 'info', app()->runningInConsole());
|
||||
do_log("cleanup count: $cleanUpCounts", 'info', isRunningInConsole());
|
||||
|
||||
$page = 1;
|
||||
$size = 10000;
|
||||
@@ -214,7 +214,7 @@ class AttendanceRepository extends BaseRepository
|
||||
$query->where('uid', $uid);
|
||||
}
|
||||
$result = $query->get();
|
||||
do_log("$logPrefix, " . last_query() . ", count: " . $result->count(), 'info', app()->runningInConsole());
|
||||
do_log("$logPrefix, " . last_query() . ", count: " . $result->count(), 'info', isRunningInConsole());
|
||||
if ($result->isEmpty()) {
|
||||
do_log("$logPrefix, no more data...");
|
||||
break;
|
||||
@@ -234,16 +234,16 @@ class AttendanceRepository extends BaseRepository
|
||||
$page++;
|
||||
}
|
||||
if (empty($insert)) {
|
||||
do_log("no data to insert...", 'info', app()->runningInConsole());
|
||||
do_log("no data to insert...", 'info', isRunningInConsole());
|
||||
return 0;
|
||||
}
|
||||
$sql = sprintf(
|
||||
"insert into `%s` (`uid`, `points`, `date`) values %s on duplicate key update `points` = values(`points`)",
|
||||
"insert into `%s` (`uid`, `points`, `date`) values %s on duplicate key update `uid` = values(`uid`)",
|
||||
$table, implode(',', $insert)
|
||||
);
|
||||
NexusDB::statement($sql);
|
||||
$insertCount = count($insert);
|
||||
do_log("[MIGRATE_ATTENDANCE_LOGS] DONE! insert sql: " . $sql, 'info', app()->runningInConsole());
|
||||
do_log("[MIGRATE_ATTENDANCE_LOGS] DONE! insert sql: " . $sql, 'info', isRunningInConsole());
|
||||
|
||||
return $insertCount;
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ class SearchRepository extends BaseRepository
|
||||
if (isset($response['errors']) && $response['errors'] == true) {
|
||||
$msg .= var_export($response, true);
|
||||
}
|
||||
do_log($msg, 'info', app()->runningInConsole());
|
||||
do_log($msg, 'info', isRunningInConsole());
|
||||
}
|
||||
|
||||
private function getTorrentId($id): string
|
||||
|
||||
@@ -373,14 +373,13 @@ class TorrentRepository extends BaseRepository
|
||||
|
||||
private function getTrackerReportAuthKeySecret($id, $uid, $initializeIfNotExists = false)
|
||||
{
|
||||
$secret = NexusDB::remember("tracker_report_authkey_secret:$id:$uid", 3600*24, function () use ($id, $uid) {
|
||||
return TorrentSecret::query()
|
||||
->where('uid', $uid)
|
||||
->whereIn('torrent_id', [0, $id])
|
||||
->orderBy('torrent_id', 'desc')
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
});
|
||||
$secret = TorrentSecret::query()
|
||||
->where('uid', $uid)
|
||||
->whereIn('torrent_id', [0, $id])
|
||||
->orderBy('torrent_id', 'desc')
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
|
||||
if ($secret) {
|
||||
return $secret->secret;
|
||||
}
|
||||
@@ -390,6 +389,7 @@ class TorrentRepository extends BaseRepository
|
||||
'torrent_id' => 0,
|
||||
'secret' => Str::random(),
|
||||
];
|
||||
do_log("[INSERT_TORRENT_SECRET] " . json_encode($insert));
|
||||
TorrentSecret::query()->insert($insert);
|
||||
return $insert['secret'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user