diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 5f8228ad..7c984b73 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -14,6 +14,7 @@ use App\Repositories\ExamRepository; use App\Repositories\SeedBoxRepository; use App\Repositories\UploadRepository; use Illuminate\Console\Command; +use Illuminate\Support\Facades\DB; use Nexus\PTGen\PTGen; use NexusPlugin\Menu\Filament\MenuItemResource\Pages\ManageMenuItems; use NexusPlugin\Menu\MenuRepository; @@ -59,7 +60,15 @@ class Test extends Command */ public function handle() { + $failedJob = DB::table('failed_jobs')->find(555); + $payload = json_decode($failedJob->payload, true); + dd($payload); + + $base64 = $payload['data']['command']; + $job = unserialize($base64); + + dd($job); } } diff --git a/app/Filament/Resources/Oauth/AuthCodeResource.php b/app/Filament/Resources/Oauth/AuthCodeResource.php index 9541ec70..0333c55f 100644 --- a/app/Filament/Resources/Oauth/AuthCodeResource.php +++ b/app/Filament/Resources/Oauth/AuthCodeResource.php @@ -46,7 +46,7 @@ class AuthCodeResource extends Resource return $table ->columns([ Tables\Columns\TextColumn::make('id'), - Tables\Columns\TextColumn::make('user.username') + Tables\Columns\TextColumn::make('user_id') ->label(__('label.username')) ->formatStateUsing(fn ($record) => username_for_admin($record->user_id)), Tables\Columns\TextColumn::make('client.name') diff --git a/app/Jobs/CalculateUserSeedBonus.php b/app/Jobs/CalculateUserSeedBonus.php index eff77bd9..99602f58 100644 --- a/app/Jobs/CalculateUserSeedBonus.php +++ b/app/Jobs/CalculateUserSeedBonus.php @@ -90,6 +90,7 @@ class CalculateUserSeedBonus implements ShouldQueue do_log("$logPrefix, [GET_UID_REAL], count: " . count($results) . ", logFile: $logFile"); $fd = fopen($logFile, 'a'); $seedPointsUpdates = $seedPointsPerHourUpdates = $seedBonusUpdates = []; + $seedingTorrentCountUpdates = $seedingTorrentSizeUpdates = []; $logStr = ""; foreach ($results as $userInfo) { @@ -129,6 +130,8 @@ class CalculateUserSeedBonus implements ShouldQueue // NexusDB::statement($sql); $seedPointsUpdates[] = sprintf("when %d then ifnull(seed_points, 0) + %f", $uid, $seed_points); $seedPointsPerHourUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['seed_points']); + $seedingTorrentCountUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['count']); + $seedingTorrentSizeUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['size']); $seedBonusUpdates[] = sprintf("when %d then seedbonus + %f", $uid, $all_bonus); if ($fd) { $log = sprintf( @@ -145,8 +148,8 @@ class CalculateUserSeedBonus implements ShouldQueue } $nowStr = now()->toDateTimeString(); $sql = sprintf( - "update users set seed_points = case id %s end, seed_points_per_hour = case id %s end, seedbonus = case id %s end, seed_points_updated_at = '%s' where id in (%s)", - implode(" ", $seedPointsUpdates), implode(" ", $seedPointsPerHourUpdates), implode(" ", $seedBonusUpdates), $nowStr, $idStr + "update users set seed_points = case id %s end, seed_points_per_hour = case id %s end, seedbonus = case id %s end, seeding_torrent_count = case id %s end, seeding_torrent_size = case id %s end, seed_points_updated_at = '%s' where id in (%s)", + implode(" ", $seedPointsUpdates), implode(" ", $seedPointsPerHourUpdates), implode(" ", $seedBonusUpdates), implode(" ", $seedingTorrentCountUpdates), implode(" ", $seedingTorrentSizeUpdates), $nowStr, $idStr ); $result = NexusDB::statement($sql); if ($delIdRedisKey) { diff --git a/app/Jobs/CheckCleanup.php b/app/Jobs/CheckCleanup.php index 570f002a..2378bab0 100644 --- a/app/Jobs/CheckCleanup.php +++ b/app/Jobs/CheckCleanup.php @@ -12,7 +12,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; -class CheckCleanup implements ShouldQueue +class CheckCleanup { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; diff --git a/app/Repositories/UpgradeRepository.php b/app/Repositories/UpgradeRepository.php new file mode 100644 index 00000000..0f08e311 --- /dev/null +++ b/app/Repositories/UpgradeRepository.php @@ -0,0 +1,20 @@ + ['editdate'], + 'invites' => ['time_invited'], + 'offers' => ['allowedtime'], + 'peers' => ['last_action', 'prev_action'], + 'posts' => ['editdate'], + 'snatched' => ['last_action', 'completedat'], + 'torrents' => ['last_action', 'promotion_until', 'picktime', 'last_reseed'], + 'users' => [ + 'last_login', 'last_access', 'last_home', 'last_offer', 'forum_access', 'last_staffmsg', + 'last_pm', 'last_comment', 'last_post', 'donoruntil', 'warneduntil', 'noaduntil', 'vip_until', + 'leechwarnuntil', 'lastwarned', + ], + ]; +} diff --git a/database/migrations/2022_04_05_022036_handle_not_null_default_0000_datetime.php b/database/migrations/2022_04_05_022036_handle_not_null_default_0000_datetime.php index 9ed075ed..8d1f57fb 100644 --- a/database/migrations/2022_04_05_022036_handle_not_null_default_0000_datetime.php +++ b/database/migrations/2022_04_05_022036_handle_not_null_default_0000_datetime.php @@ -13,20 +13,7 @@ return new class extends Migration */ public function up() { - $tableFields = [ - 'comments' => ['editdate'], - 'invites' => ['time_invited'], - 'offers' => ['allowedtime'], - 'peers' => ['last_action', 'prev_action'], - 'posts' => ['editdate'], - 'snatched' => ['last_action', 'completedat'], - 'torrents' => ['last_action', 'promotion_until', 'picktime', 'last_reseed'], - 'users' => [ - 'last_login', 'last_access', 'last_home', 'last_offer', 'forum_access', 'last_staffmsg', - 'last_pm', 'last_comment', 'last_post', 'donoruntil', 'warneduntil', 'noaduntil', 'vip_until', - 'leechwarnuntil', 'lastwarned', - ], - ]; + $tableFields = \App\Repositories\UpgradeRepository::DATETIME_INVALID_VALUE_FIELDS; foreach ($tableFields as $table => $fields) { $columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo($table); diff --git a/database/migrations/2025_06_03_140409_add_seeding_torrent_count_field_to_users_table.php b/database/migrations/2025_06_03_140409_add_seeding_torrent_count_field_to_users_table.php new file mode 100644 index 00000000..6a2b82e9 --- /dev/null +++ b/database/migrations/2025_06_03_140409_add_seeding_torrent_count_field_to_users_table.php @@ -0,0 +1,30 @@ +integer("seeding_torrent_count")->default(0); + $table->bigInteger("seeding_torrent_size")->default(0); + $table->dateTime("last_announce_at")->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn("seeding_torrent_count", "seeding_torrent_size", "last_announce_at"); + }); + } +}; diff --git a/database/migrations/2025_06_04_153154_update_invalid_datetime_value.php b/database/migrations/2025_06_04_153154_update_invalid_datetime_value.php new file mode 100644 index 00000000..775cce11 --- /dev/null +++ b/database/migrations/2025_06_04_153154_update_invalid_datetime_value.php @@ -0,0 +1,37 @@ + $fields) { + $columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo($table); + foreach ($fields as $field) { + if (isset($columnInfo[$field]) && $columnInfo[$field]['DATA_TYPE'] == 'datetime') { + \Illuminate\Support\Facades\DB::statement("update $table set $field = null where $field = '0000-00-00 00:00:00'"); + } + } + } + $columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo("snatched"); + if (isset($columnInfo["finish_ip"])) { + \Illuminate\Support\Facades\DB::statement("alter table snatched drop column finish_ip"); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +}; diff --git a/include/constants.php b/include/constants.php index 65b18d67..c4ab8af0 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@