Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/Jobs/CirrusSearch/QueueSearchIndexBatches.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs\CirrusSearch;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Log;

/**
Expand All @@ -13,8 +12,6 @@
* php artisan job:dispatch CirrusSearch\\QueueSearchIndexBatches 1
*/
class QueueSearchIndexBatches extends CirrusSearchJob {
use DispatchesJobs;

public function apiModule(): string {
return 'wbstackQueueSearchIndexBatches';
}
Expand Down
3 changes: 0 additions & 3 deletions app/Jobs/ElasticSearchAliasInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

use App\Http\Curl\HttpRequest;
use App\WikiDb;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Support\Facades\Log;

class ElasticSearchAliasInit extends Job {
use Dispatchable;

public readonly int $wikiId;

public readonly string $esHost;
Expand Down
6 changes: 1 addition & 5 deletions app/Jobs/FailStalledEntityImportsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
use App\WikiEntityImport;
use App\WikiEntityImportStatus;
use Carbon\Carbon;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Log;

class FailStalledEntityImportsJob implements ShouldQueue {
use Queueable;

class FailStalledEntityImportsJob extends Job {
public function handle(): void {
$deadline = Carbon::now()->subHours(24);
$now = Carbon::now();
Expand Down
6 changes: 1 addition & 5 deletions app/Jobs/GenerateOAuth2KeysJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@

use App\Wiki;
use App\WikiSetting;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Log;

class GenerateOAuth2KeysJob extends Job implements ShouldQueue {
use Queueable;

class GenerateOAuth2KeysJob extends Job {
public function handle() {
$allWikis = Wiki::all();

Expand Down
16 changes: 2 additions & 14 deletions app/Jobs/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,12 @@

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Config;

abstract class Job implements ShouldQueue {
/*
|--------------------------------------------------------------------------
| Queueable Jobs
|--------------------------------------------------------------------------
|
| This job base class provides a central location to place any logic that
| is shared across all of your jobs. The trait included with the class
| provides access to the "queueOn" and "delay" queue helper methods.
|
*/
use InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

public $timeout = 60;

Expand Down
3 changes: 1 addition & 2 deletions app/Jobs/PollForMediaWikiJobsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
use App\Services\UnknownWikiDomainException;
use App\Wiki;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

class PollForMediaWikiJobsJob extends Job implements ShouldBeUnique, ShouldQueue {
class PollForMediaWikiJobsJob extends Job implements ShouldBeUnique {
private MediaWikiHostResolver $mwHostResolver;

public $timeout = 1800;
Expand Down
7 changes: 1 addition & 6 deletions app/Jobs/ProcessMediaWikiJobsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
namespace App\Jobs;

use App\Services\MediaWikiHostResolver;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Maclof\Kubernetes\Client;
use Maclof\Kubernetes\Models\Job as KubernetesJob;

class ProcessMediaWikiJobsJob implements ShouldBeUnique, ShouldQueue {
use InteractsWithQueue, Queueable;

class ProcessMediaWikiJobsJob extends Job implements ShouldBeUnique {
private string $wikiDomain;

private string $jobsKubernetesNamespace;
Expand Down
7 changes: 1 addition & 6 deletions app/Jobs/SpawnQueryserviceUpdaterJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Maclof\Kubernetes\Client;
use Maclof\Kubernetes\Models\Job as KubernetesJob;

class SpawnQueryserviceUpdaterJob implements ShouldBeUnique, ShouldQueue {
use InteractsWithQueue, Queueable;

class SpawnQueryserviceUpdaterJob extends Job implements ShouldBeUnique {
public string $wikiDomain;

public string $entities;
Expand Down
3 changes: 0 additions & 3 deletions app/Jobs/UpdateWikiDailyMetricJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
use App\Metrics\App\WikiMetrics;
use App\Wiki;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Foundation\Bus\Dispatchable;

// This job is for the daily measurements of metrics per wikibases.
// This is to help in understanding the purpose of active wikis.
class UpdateWikiDailyMetricJob extends Job implements ShouldBeUnique {
use Dispatchable;

public $timeout = 3600;

/**
Expand Down
3 changes: 0 additions & 3 deletions app/Jobs/UpdateWikiSiteStatsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@
use Carbon\Carbon;
use Carbon\CarbonInterface;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

class UpdateWikiSiteStatsJob extends Job implements ShouldBeUnique {
use Dispatchable;

public $timeout = 3600;

private MediaWikiHostResolver $mwHostResolver;
Expand Down
6 changes: 1 addition & 5 deletions app/Jobs/WikiEntityImportJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@
use App\WikiEntityImport;
use App\WikiEntityImportStatus;
use Carbon\Carbon;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Maclof\Kubernetes\Client;
use Maclof\Kubernetes\Models\Job as KubernetesJob;

class WikiEntityImportJob implements ShouldQueue {
use Queueable;

class WikiEntityImportJob extends Job {
/**
* Create a new job instance.
*/
Expand Down
42 changes: 42 additions & 0 deletions tests/Architecture/JobsInheritBaseClassTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Tests\Architecture;

use App\Jobs\Job;
use Illuminate\Contracts\Queue\ShouldQueue;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use ReflectionClass;

class JobsInheritBaseClassTest extends TestCase {
#[DataProvider('provideQueuedJobClasses')]
public function testQueuedJobsExtendApplicationJob(string $jobClass): void {
$this->assertTrue(is_subclass_of($jobClass, Job::class));
}

public static function provideQueuedJobClasses(): iterable {
$jobsPath = realpath(dirname(__DIR__, 2) . '/app/Jobs');
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($jobsPath));
foreach ($files as $file) {
if ($file->isFile() && $file->getExtension() === 'php') {
require_once $file->getPathname();
}
}

foreach (get_declared_classes() as $class) {
$reflection = new ReflectionClass($class);
$fileName = $reflection->getFileName();

if (
$fileName !== false
&& str_starts_with($fileName, $jobsPath . DIRECTORY_SEPARATOR)
&& $class !== Job::class
&& $reflection->implementsInterface(ShouldQueue::class)
) {
yield $class => [$class];
}
}
}
}
Loading