1 | <?php |
||
36 | class QueueRepository extends AbstractRepository |
||
37 | { |
||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $tableName = 'tx_crawler_queue'; |
||
42 | |||
43 | /** |
||
44 | * This method is used to find the youngest entry for a given process. |
||
45 | * |
||
46 | * @param Process $process |
||
47 | * |
||
48 | * @return Queue $entry |
||
49 | */ |
||
50 | 1 | public function findYoungestEntryForProcess(Process $process) |
|
54 | |||
55 | /** |
||
56 | * This method is used to find the oldest entry for a given process. |
||
57 | * |
||
58 | * @param Process $process |
||
59 | * |
||
60 | * @return Queue |
||
61 | */ |
||
62 | 1 | public function findOldestEntryForProcess(Process $process) |
|
66 | |||
67 | /** |
||
68 | * This internal helper method is used to create an instance of an entry object |
||
69 | * |
||
70 | * @param Process $process |
||
71 | * @param string $orderby first matching item will be returned as object |
||
72 | * |
||
73 | * @return Queue |
||
74 | */ |
||
75 | 5 | protected function getFirstOrLastObjectByProcess($process, $orderby) |
|
93 | |||
94 | /** |
||
95 | * Counts all executed items of a process. |
||
96 | * |
||
97 | * @param Process $process |
||
98 | * |
||
99 | * @return int |
||
100 | */ |
||
101 | 1 | public function countExecutedItemsByProcess($process) |
|
108 | |||
109 | /** |
||
110 | * Counts items of a process which yet have not been processed/executed |
||
111 | * |
||
112 | * @param Process $process |
||
113 | * |
||
114 | * @return int |
||
115 | */ |
||
116 | 1 | public function countNonExecutedItemsByProcess($process) |
|
123 | |||
124 | /** |
||
125 | * Count items which have not been processed yet |
||
126 | * |
||
127 | * @return int |
||
128 | */ |
||
129 | 1 | public function countUnprocessedItems() |
|
130 | { |
||
131 | 1 | return $this->countItemsByWhereClause("exec_time=0 AND process_scheduled=0 AND scheduled<=" . time()); |
|
132 | } |
||
133 | |||
134 | /** |
||
135 | * This method can be used to count all queue entrys which are |
||
136 | * scheduled for now or a earlier date. |
||
137 | * |
||
138 | * @return int |
||
139 | */ |
||
140 | 2 | public function countAllPendingItems() |
|
144 | |||
145 | /** |
||
146 | * This method can be used to count all queue entrys which are |
||
147 | * scheduled for now or a earlier date and are assigned to a process. |
||
148 | * |
||
149 | * @return int |
||
150 | */ |
||
151 | 2 | public function countAllAssignedPendingItems() |
|
155 | |||
156 | /** |
||
157 | * This method can be used to count all queue entrys which are |
||
158 | * scheduled for now or a earlier date and are not assigned to a process. |
||
159 | * |
||
160 | * @return int |
||
161 | */ |
||
162 | 1 | public function countAllUnassignedPendingItems() |
|
166 | |||
167 | /** |
||
168 | * Internal method to count items by a given where clause |
||
169 | * |
||
170 | * @param string $where |
||
171 | * |
||
172 | * @return mixed |
||
173 | */ |
||
174 | 9 | protected function countItemsByWhereClause($where) |
|
182 | |||
183 | /** |
||
184 | * Count pending queue entries grouped by configuration key |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | 1 | public function countPendingItemsGroupedByConfigurationKey() |
|
204 | |||
205 | /** |
||
206 | * Get set id with unprocessed entries |
||
207 | * |
||
208 | * @param void |
||
209 | * |
||
210 | * @return array array of set ids |
||
211 | */ |
||
212 | 1 | public function getSetIdWithUnprocessedEntries() |
|
228 | |||
229 | /** |
||
230 | * Get total queue entries by configuration |
||
231 | * |
||
232 | * @param array $setIds |
||
233 | * |
||
234 | * @return array totals by configuration (keys) |
||
235 | */ |
||
236 | 1 | public function getTotalQueueEntriesByConfiguration(array $setIds) |
|
254 | |||
255 | /** |
||
256 | * Get the timestamps of the last processed entries |
||
257 | * |
||
258 | * @param int $limit |
||
259 | * |
||
260 | * @return array |
||
261 | */ |
||
262 | 1 | public function getLastProcessedEntriesTimestamps($limit = 100) |
|
281 | |||
282 | /** |
||
283 | * Get the last processed entries |
||
284 | * |
||
285 | * @param string $selectFields |
||
286 | * @param int $limit |
||
287 | * |
||
288 | * @return array |
||
289 | */ |
||
290 | 1 | public function getLastProcessedEntries($selectFields = '*', $limit = 100) |
|
309 | |||
310 | /** |
||
311 | * Get performance statistics data |
||
312 | * |
||
313 | * @param int $start timestamp |
||
314 | * @param int $end timestamp |
||
315 | * |
||
316 | * @return array performance data |
||
317 | */ |
||
318 | 1 | public function getPerformanceData($start, $end) |
|
335 | |||
336 | /** |
||
337 | * This method is used to count all processes in the process table. |
||
338 | * |
||
339 | * @param string $where Where clause |
||
340 | * |
||
341 | * @return integer |
||
342 | */ |
||
343 | 8 | public function countAll($where = '1 = 1') |
|
347 | } |
||
348 |