mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
recover ptGen
This commit is contained in:
@@ -7,11 +7,13 @@ use App\Models\ExamUser;
|
||||
use App\Models\Language;
|
||||
use App\Models\PersonalAccessToken;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\TorrentExtra;
|
||||
use App\Models\User;
|
||||
use App\Repositories\ExamRepository;
|
||||
use App\Repositories\SeedBoxRepository;
|
||||
use App\Repositories\UploadRepository;
|
||||
use Illuminate\Console\Command;
|
||||
use Nexus\PTGen\PTGen;
|
||||
use NexusPlugin\Menu\Filament\MenuItemResource\Pages\ManageMenuItems;
|
||||
use NexusPlugin\Menu\MenuRepository;
|
||||
use NexusPlugin\Menu\Models\MenuItem;
|
||||
@@ -56,7 +58,7 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Language::updateTransStatus();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class MigrateTorrentsTableTextColumn extends Command
|
||||
public function handle()
|
||||
{
|
||||
if (Schema::hasTable("torrent_extras") && Schema::hasColumn("torrents", "descr")) {
|
||||
NexusDB::statement("insert into torrent_extras (torrent_id, descr, media_info, nfo, created_at) select id, descr, technical_info, nfo, now() from torrents on duplicate key update torrent_id = values(torrent_id)");
|
||||
NexusDB::statement("insert into torrent_extras (torrent_id, descr, media_info, nfo, pt_gen, created_at) select id, descr, technical_info, nfo, pt_gen, now() from torrents on duplicate key update torrent_id = values(torrent_id)");
|
||||
}
|
||||
$columns = ["ori_descr", "descr", "nfo", "technical_info", "pt_gen"];
|
||||
$sql = "alter table torrents ";
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Models\Torrent;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Nexus\PTGen\PTGen;
|
||||
|
||||
class FetchTorrentPTGen implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(object $event): void
|
||||
{
|
||||
$logPrefix = "FetchTorrentPTGen";
|
||||
if (!Setting::getIsPTGenEnabled()) {
|
||||
do_log("$logPrefix, PTGen is disabled");
|
||||
return;
|
||||
}
|
||||
$torrent = $event->model;
|
||||
if (!$torrent instanceof Torrent) {
|
||||
do_log("$logPrefix, not Torrent: " . Torrent::class);
|
||||
return;
|
||||
}
|
||||
$torrentId = $torrent->id ?? 0;
|
||||
if (empty($torrentId)) {
|
||||
do_log("$logPrefix, no torrent_id");
|
||||
return;
|
||||
}
|
||||
$torrentTool = new PTGen();
|
||||
$torrentTool->updateTorrentPtGen($torrentId);
|
||||
do_log("FetchTorrentPTGen for torrent: $torrentId done!");
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class NexusFormatter
|
||||
$id = nexus()->getRequestId();
|
||||
}
|
||||
$format = "[%datetime%] [" . $id . "] %channel%.%level_name%: %message% %context% %extra%\n";
|
||||
return tap(new LineFormatter($format, 'Y-m-d H:i:s', true, true), function ($formatter) {
|
||||
return tap(new LineFormatter($format, "Y-m-d\TH:i:s.vP", true, true), function ($formatter) {
|
||||
$formatter->includeStacktraces();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,6 +120,11 @@ class Setting extends NexusModel
|
||||
return self::get("main.defaultlang");
|
||||
}
|
||||
|
||||
public static function getIsPTGenEnabled(): bool
|
||||
{
|
||||
return self::get("main.enable_pt_gen_system") == "yes";
|
||||
}
|
||||
|
||||
public static function getIsUseChallengeResponseAuthentication(): bool
|
||||
{
|
||||
return self::get("security.use_challenge_response_authentication") == "yes";
|
||||
|
||||
@@ -9,7 +9,11 @@ class TorrentExtra extends NexusModel
|
||||
{
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = ['torrent_id', 'descr', 'ori_descr', 'media_info', 'nfo'];
|
||||
protected $fillable = ['torrent_id', 'descr', 'ori_descr', 'media_info', 'nfo', 'pt_gen'];
|
||||
|
||||
protected $casts = [
|
||||
'pt_gen' => 'array',
|
||||
];
|
||||
|
||||
public function torrent()
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Events\UserDeleted;
|
||||
use App\Events\UserDisabled;
|
||||
use App\Listeners\DeductUserBonusWhenTorrentDeleted;
|
||||
use App\Listeners\FetchTorrentImdb;
|
||||
use App\Listeners\FetchTorrentPTGen;
|
||||
use App\Listeners\RemoveOauthTokens;
|
||||
use App\Listeners\RemoveSeedBoxRecordCache;
|
||||
use App\Listeners\SendEmailNotificationWhenTorrentCreated;
|
||||
@@ -41,6 +42,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
],
|
||||
TorrentCreated::class => [
|
||||
FetchTorrentImdb::class,
|
||||
FetchTorrentPTGen::class,
|
||||
SyncTorrentToElasticsearch::class,
|
||||
SyncTorrentToMeilisearch::class,
|
||||
SendEmailNotificationWhenTorrentCreated::class,
|
||||
|
||||
@@ -128,7 +128,7 @@ class ClaimRepository extends BaseRepository
|
||||
{
|
||||
$startOfThisMonth = Carbon::now()->startOfMonth();
|
||||
$query = Claim::query()
|
||||
->selectRaw("uid, count(*) as count)")
|
||||
->selectRaw("uid, count(*) as count")
|
||||
->where("created_at", "<", $startOfThisMonth)
|
||||
->where(function (Builder $query) use ($startOfThisMonth) {
|
||||
$query->where('last_settle_at', '<', $startOfThisMonth)->orWhereNull('last_settle_at');
|
||||
|
||||
Reference in New Issue
Block a user