44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Console;
|
|
|
|
use App\Jobs\AISerpGenArticleJob;
|
|
use Carbon\Carbon;
|
|
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
|
|
{
|
|
|
|
// AI Gen Scheduler
|
|
|
|
$launched_date = Carbon::parse(config('platform.global.launched_epoch'));
|
|
$days_since_launch = now()->diffInDays($launched_date) + 1;
|
|
|
|
$posts_to_generate = get_exponential_posts_gen_by_day($days_since_launch);
|
|
$mins_betwween_posts = floor((24 * 60) / $posts_to_generate);
|
|
|
|
$schedule->call(function () {
|
|
AISerpGenArticleJob::dispatch()->onQueue('default')->onConnection('default');
|
|
|
|
})->everyMinutes($mins_betwween_posts)->when(function () use ($mins_betwween_posts) {
|
|
return now()->minute % $mins_betwween_posts === 0;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Register the commands for the application.
|
|
*/
|
|
protected function commands(): void
|
|
{
|
|
$this->load(__DIR__.'/Commands');
|
|
|
|
require base_path('routes/console.php');
|
|
}
|
|
}
|