<?php

use App\Jobs\ArticleDiscoveryJob;
use App\Jobs\CheckFeedStalenessJob;
use App\Jobs\CheckPlatformCredentialsJob;
use App\Jobs\CleanupActivityLogsJob;
use App\Jobs\CleanupArticlesJob;
use App\Jobs\PublishNextArticleJob;
use App\Jobs\SyncChannelPostsJob;
use Illuminate\Support\Facades\Schedule;

Schedule::call(function () {
    SyncChannelPostsJob::dispatchForAllActiveChannels();
})->everyTenMinutes()->name('sync-lemmy-channel-posts');

Schedule::job(new PublishNextArticleJob)
    ->everyFiveMinutes()
    ->name('publish-next-article')
    ->withoutOverlapping()
    ->onOneServer();

Schedule::job(new ArticleDiscoveryJob)
    ->everyThirtyMinutes()
    ->name('refresh-articles')
    ->withoutOverlapping()
    ->onOneServer();

Schedule::job(new CheckFeedStalenessJob)
    ->hourly()
    ->name('check-feed-staleness')
    ->withoutOverlapping()
    ->onOneServer();

Schedule::job(new CheckPlatformCredentialsJob)
    ->daily()
    ->name('check-platform-credentials')
    ->withoutOverlapping()
    ->onOneServer();

Schedule::job(new CleanupArticlesJob)
    ->daily()
    ->name('cleanup-old-articles')
    ->withoutOverlapping()
    ->onOneServer();

Schedule::job(new CleanupActivityLogsJob)
    ->daily()
    ->name('cleanup-activity-logs')
    ->withoutOverlapping()
    ->onOneServer();
