EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/296431
Change subject: Allow console to import specific pending query
......................................................................
Allow console to import specific pending query
If a query was already marked as pending there was no way to finish
importing it other than running the import queue.
Change-Id: Id2caf929a5297df326a30f6f2fbee0901a92b6e2
---
M src/RelevanceScoring/Import/Importer.php
1 file changed, 18 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/discovery/discernatron
refs/changes/31/296431/1
diff --git a/src/RelevanceScoring/Import/Importer.php
b/src/RelevanceScoring/Import/Importer.php
index 3b1ba79..e652f6d 100644
--- a/src/RelevanceScoring/Import/Importer.php
+++ b/src/RelevanceScoring/Import/Importer.php
@@ -52,22 +52,34 @@
$callable($line);
}
- public function import(User $user, $wiki, $query)
+ public function import(User $user, $wiki, $queryString)
{
if (!isset($this->wikis[$wiki])) {
throw new RuntimeException("Unknown wiki: $wiki");
}
- $maybeQueryId = $this->queriesRepo->findQueryId($wiki, $query);
+ $maybeQueryId = $this->queriesRepo->findQueryId($wiki, $queryString);
+ $queryId = null;
if ($maybeQueryId->nonEmpty()) {
- throw new RuntimeException('Query already imported');
+ $queryId = $maybeQueryId->get();
+ $maybeQuery = $this->queriesRepo->getQuery($queryId);
+ if ($maybeQuery->isEmpty()) {
+ throw new RuntimeException('Found query id but not
query?!?!?');
+ }
+ $query = $maybeQuery->get();
+ if ($query['imported']) {
+ throw new RuntimeException('Query already imported');
+ }
}
- $results = $this->performSearch($wiki, $query);
+ $results = $this->performSearch($wiki, $queryString);
- $this->db->transactional(function () use ($user, $wiki, $query,
$results) {
- $queryId = $this->queriesRepo->createQuery($user, $wiki, $query,
'imported');
+ $this->db->transactional(function () use ($queryId, $user, $wiki,
$queryString, $results) {
+ if ($queryId === null) {
+ $queryId = $this->queriesRepo->createQuery($user, $wiki,
$queryString, 'imported');
+ }
$this->resultsRepo->storeResults($user, $queryId, $results);
$this->scoringQueueRepo->insert($queryId);
+ $this->queriesRepo->markQueryImported($queryId);
});
return count($results);
--
To view, visit https://gerrit.wikimedia.org/r/296431
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id2caf929a5297df326a30f6f2fbee0901a92b6e2
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/discovery/discernatron
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits