mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
fix bugs
This commit is contained in:
@@ -35,6 +35,7 @@ use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use JeroenG\Explorer\Domain\Syntax\Matching;
|
||||
use JeroenG\Explorer\Infrastructure\Scout\ElasticEngine;
|
||||
use Nexus\Database\NexusDB;
|
||||
use Rhilip\Bencode\Bencode;
|
||||
|
||||
class Test extends Command
|
||||
@@ -70,11 +71,11 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$searchRep = new SearchRepository();
|
||||
$r = $searchRep->deleteIndex();
|
||||
$r = $searchRep->createIndex();
|
||||
$r = $searchRep->import();
|
||||
dd($r);
|
||||
// $searchRep = new SearchRepository();
|
||||
// $r = $searchRep->deleteIndex();
|
||||
// $r = $searchRep->createIndex();
|
||||
// $r = $searchRep->import();
|
||||
// dd($r);
|
||||
//
|
||||
// $arr = [
|
||||
// 'cat' => 'category',
|
||||
@@ -129,6 +130,12 @@ class Test extends Command
|
||||
// dd($today->diffInDays($yesterday));
|
||||
// $r = get_smile(12);
|
||||
// dd($r);
|
||||
|
||||
// $key = "dddd1";
|
||||
// $model = \App\Models\TorrentSecret::query()->where('id', 1)->first();
|
||||
// \Nexus\Database\NexusDB::cache_put($key, $model);
|
||||
$value = NexusDB::cache_get("tracker_report_authkey_secret:1:10002");
|
||||
dd($value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class Locale
|
||||
|
||||
/** @var Response $response */
|
||||
$response = $next($request);
|
||||
$response->header('Request-Id', nexus()->getRequestId());
|
||||
$response->header('Request-Id', nexus()->getRequestId())->header('Running-In-Octane', RUNNING_IN_OCTANE ? 1 : 0);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
@@ -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