Skip to content

Commit e340b98

Browse files
authored
feat: Dispatch jobs for rebuilding Queryservice data to non-default queue (#710)
1 parent bf25179 commit e340b98

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# api
22

3+
## 8x.31.0 - 14 December 2023
4+
- Dispatch jobs for rebuilding Queryservice data to non-default queue
5+
36
## 8x.30.0 - 14 December 2023
47
- Allow passing a queue name to the worker
58

app/Console/Commands/RebuildQueryserviceData.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Console\Command;
66
use Illuminate\Support\Facades\Http;
77
use Illuminate\Support\Facades\Log;
8+
use Illuminate\Support\Facades\Queue;
89
use App\Wiki;
910
use App\WikiSetting;
1011
use App\QueryserviceNamespace;
@@ -16,18 +17,20 @@ class RebuildQueryserviceData extends Command
1617
private const NAMESPACE_PROPERTY = 122;
1718
private const NAMESPACE_LEXEME = 146;
1819

19-
protected $signature = 'wbs-qs:rebuild {--domain=*} {--chunkSize=50} {--sparqlUrlFormat=http://queryservice.default.svc.cluster.local:9999/bigdata/namespace/%s/sparql}';
20+
protected $signature = 'wbs-qs:rebuild {--domain=*} {--chunkSize=50} {--queueName=manual-intervention} {--sparqlUrlFormat=http://queryservice.default.svc.cluster.local:9999/bigdata/namespace/%s/sparql}';
2021

2122
protected $description = 'Rebuild the queryservice data for a certain wiki or all wikis';
2223

2324
protected int $chunkSize;
2425
protected string $apiUrl;
2526
protected string $sparqlUrlFormat;
27+
protected string $queueName;
2628

2729
public function handle()
2830
{
2931
$this->chunkSize = intval($this->option('chunkSize'));
3032
$this->sparqlUrlFormat = $this->option('sparqlUrlFormat');
33+
$this->queueName = $this->option('queueName');
3134
$this->apiUrl = getenv('PLATFORM_MW_BACKEND_HOST').'/w/api.php';
3235

3336
$wikiDomains = $this->option('domain');
@@ -56,13 +59,11 @@ public function handle()
5659

5760
$entityChunks = array_chunk($entities, $this->chunkSize);
5861
foreach ($entityChunks as $entityChunk) {
59-
dispatch(
60-
new SpawnQueryserviceUpdaterJob(
61-
$wiki->domain,
62-
implode(',', $entityChunk),
63-
$sparqlUrl,
64-
)
65-
);
62+
Queue::pushOn($this->queueName, new SpawnQueryserviceUpdaterJob(
63+
$wiki->domain,
64+
implode(',', $entityChunk),
65+
$sparqlUrl,
66+
));
6667
}
6768
$jobTotal += count($entityChunks);
6869
$processedWikis += 1;

0 commit comments

Comments
 (0)