|
1
|
|
|
<?php |
|
2
|
|
|
/****************************************************************************** |
|
3
|
|
|
* Wikipedia Account Creation Assistance tool * |
|
4
|
|
|
* * |
|
5
|
|
|
* All code in this file is released into the public domain by the ACC * |
|
6
|
|
|
* Development Team. Please see team.json for a list of contributors. * |
|
7
|
|
|
******************************************************************************/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Waca\Helpers\SearchHelpers; |
|
10
|
|
|
|
|
11
|
|
|
use Waca\DataObjects\JobQueue; |
|
12
|
|
|
use Waca\PdoDatabase; |
|
13
|
|
|
|
|
14
|
|
|
class JobQueueSearchHelper extends SearchHelperBase |
|
15
|
|
|
{ |
|
16
|
|
|
protected function __construct(PdoDatabase $database) |
|
17
|
|
|
{ |
|
18
|
|
|
parent::__construct($database, 'jobqueue', JobQueue::class, null); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @param PdoDatabase $database |
|
23
|
|
|
* |
|
24
|
|
|
* @return JobQueueSearchHelper |
|
25
|
|
|
*/ |
|
26
|
|
|
public static function get(PdoDatabase $database) |
|
27
|
|
|
{ |
|
28
|
|
|
$helper = new JobQueueSearchHelper($database); |
|
29
|
|
|
return $helper; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param string[] $statuses |
|
34
|
|
|
* |
|
35
|
|
|
* @return $this |
|
36
|
|
|
*/ |
|
37
|
|
|
public function statusIn($statuses) |
|
38
|
|
|
{ |
|
39
|
|
|
$this->inClause('status', $statuses); |
|
40
|
|
|
|
|
41
|
|
|
return $this; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return $this |
|
46
|
|
|
*/ |
|
47
|
|
|
public function notAcknowledged() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->whereClause .= ' AND (acknowledged IS NULL OR acknowledged = 0)'; |
|
50
|
|
|
|
|
51
|
|
|
return $this; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function byTask($task) |
|
55
|
|
|
{ |
|
56
|
|
|
$this->whereClause .= ' AND task = ?'; |
|
57
|
|
|
$this->parameterList[] = $task; |
|
58
|
|
|
|
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function byUser($userId) |
|
63
|
|
|
{ |
|
64
|
|
|
$this->whereClause .= ' AND user = ?'; |
|
65
|
|
|
$this->parameterList[] = $userId; |
|
66
|
|
|
|
|
67
|
|
|
return $this; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function byStatus($status) |
|
71
|
|
|
{ |
|
72
|
|
|
$this->whereClause .= ' AND status = ?'; |
|
73
|
|
|
$this->parameterList[] = $status; |
|
74
|
|
|
|
|
75
|
|
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function byRequest(int $request) : JobQueueSearchHelper |
|
79
|
|
|
{ |
|
80
|
|
|
$this->whereClause .= ' AND request = ?'; |
|
81
|
|
|
$this->parameterList[] = $request; |
|
82
|
|
|
|
|
83
|
|
|
return $this; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function newestFirst() |
|
87
|
|
|
{ |
|
88
|
|
|
$this->orderBy = 'id DESC'; |
|
89
|
|
|
|
|
90
|
|
|
return $this; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|