Init
This commit is contained in:
39
app/Console/Commands/AutoStats.php
Normal file
39
app/Console/Commands/AutoStats.php
Normal 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');
|
||||
}
|
||||
}
|
51
app/Console/Commands/GenerateSitemap.php
Normal file
51
app/Console/Commands/GenerateSitemap.php
Normal 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'));
|
||||
}
|
||||
}
|
37
app/Console/Commands/GetFileSize.php
Normal file
37
app/Console/Commands/GetFileSize.php
Normal 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!');
|
||||
}
|
||||
}
|
40
app/Console/Commands/ResetUserDownloads.php
Normal file
40
app/Console/Commands/ResetUserDownloads.php
Normal 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
27
app/Console/Kernel.php
Normal 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');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user