This commit is contained in:
2025-09-18 15:31:27 +02:00
commit 2abba0c2b7
406 changed files with 31879 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands;
use App\Models\PopularDaily;
use App\Models\PopularWeekly;
use App\Models\PopularMonthly;
use Illuminate\Support\Carbon;
use Illuminate\Console\Command;
class AutoStats extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:auto-stats';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clear Outdated Popular Stats';
/**
* Execute the console command.
*/
public function handle()
{
PopularDaily::where('created_at', '<=', Carbon::now()->subMinutes(1440))->forceDelete();
PopularWeekly::where('created_at', '<=', Carbon::now()->subMinutes(10080))->forceDelete();
PopularMonthly::where('created_at', '<=', Carbon::now()->subMinutes(43200))->forceDelete();
$this->comment('Automated Purge Stats Complete');
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Console\Commands;
use App\Models\Episode;
use App\Models\Hentai;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Spatie\Sitemap\Sitemap;
use Spatie\Sitemap\Tags\Url;
class GenerateSitemap extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sitemap:generate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate the sitemap.';
/**
* Execute the console command.
*/
public function handle()
{
$latestEpisode = Episode::latest()->first();
$latestUpdate = Carbon::create($latestEpisode->created_at);
$sitemap = Sitemap::create()
->add(Url::create('/')
->setLastModificationDate($latestUpdate))
->add(Url::create('/stats')
->setLastModificationDate(Carbon::now()))
->add(Url::create('/search')
->setLastModificationDate(Carbon::now()))
->add(Url::create('/contact')
->setLastModificationDate(Carbon::create('2023', '8', '1')))
->add(Episode::all())
->add(Hentai::all());
$sitemap->writeToFile(public_path('sitemap.xml'));
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Console\Commands;
use App\Models\Downloads;
use App\Jobs\GetFileSizeFromCDN;
use Illuminate\Console\Command;
class GetFileSize extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:get-file-size';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Get missing filesize from API (Job)';
/**
* Execute the console command.
*/
public function handle()
{
foreach(Downloads::whereNull('size')->get() as $download) {
GetFileSizeFromCDN::dispatch($download->id);
}
$this->comment('Added all missing sizes to Job Queue!');
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Console\Commands;
use App\Models\User;
use App\Models\UserDownload;
use Illuminate\Support\Carbon;
use Illuminate\Console\Command;
class ResetUserDownloads extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:reset-user-downloads';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Resets the daily limit of user downloads';
/**
* Execute the console command.
*/
public function handle()
{
User::query()->update([
'downloads_left' => config('hstream.free_downloads_count'),
]);
// Clear old downloads which have expired
UserDownload::where('created_at', '<=', Carbon::now()->subHour(6))
->forceDelete();
}
}

27
app/Console/Kernel.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*/
protected function schedule(Schedule $schedule): void
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*/
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}