Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
TopicListStorage | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
doFindQuery | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
insert | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace Flow\Data\Storage; |
4 | |
5 | /** |
6 | * Storage class for topic list ordered by last updated |
7 | */ |
8 | class TopicListStorage extends BasicDbStorage { |
9 | |
10 | protected function doFindQuery( array $preprocessedAttributes, array $options = [] ) { |
11 | return $this->dbFactory->getDB( DB_REPLICA )->newSelectQueryBuilder() |
12 | ->select( [ 'topic_list_id', 'topic_id', 'workflow_last_update_timestamp' ] ) |
13 | ->from( $this->table ) |
14 | ->join( 'flow_workflow', null, 'workflow_id = topic_id' ) |
15 | ->where( $preprocessedAttributes ) |
16 | ->caller( __METHOD__ . " ({$this->table})" ) |
17 | ->options( $options ) |
18 | ->fetchResultSet(); |
19 | } |
20 | |
21 | /** |
22 | * We need workflow_last_update_timestamp for updating |
23 | * the ordering in cache |
24 | * @param array $rows |
25 | * @return array|false |
26 | */ |
27 | public function insert( array $rows ) { |
28 | $updateRows = []; |
29 | foreach ( $rows as $i => $row ) { |
30 | // Note, entries added directly to the index (rather than from DB |
31 | // fill) do have this key, but obviously it can't be used. |
32 | unset( $row['workflow_last_update_timestamp'] ); |
33 | $updateRows[$i] = $row; |
34 | } |
35 | $res = parent::insert( $updateRows ); |
36 | if ( $res ) { |
37 | return $rows; |
38 | } else { |
39 | return false; |
40 | } |
41 | } |
42 | |
43 | } |