diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-01-04 22:20:47 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-01-04 22:20:47 +0100 |
commit | fe6268cbecd05145fff3c3af4e79fb9f180fecea (patch) | |
tree | 6fb25f0d5e864db79c620473267f1dbe140f8108 /db | |
parent | 2509229184a991707420a339d9747c61c0a54654 (diff) |
generate indices for all items
Diffstat (limited to 'db')
-rw-r--r-- | db/itemmapper.php | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/db/itemmapper.php b/db/itemmapper.php index ee0ed1775..27a61db80 100644 --- a/db/itemmapper.php +++ b/db/itemmapper.php @@ -13,7 +13,7 @@ namespace OCA\News\Db; -use OCP\AppFramework\Db\DoesNotExistException; +use Exception; use OCP\IDBConnection; @@ -342,11 +342,8 @@ class ItemMapper extends NewsMapper { /** * Returns a list of ids and userid of all items */ - public function findAllItemIdsAndUsers($limit=null, $offset=null) { - $sql = 'SELECT `items`.`id`, `feeds`.`user_id` ' . - 'FROM `*PREFIX*news_items` `items` ' . - 'JOIN `*PREFIX*news_feeds` `feeds` ' . - 'ON `items`.`feed_id` = `feeds`.`id`'; + public function findAllIds($limit=null, $offset=null) { + $sql = 'SELECT `id` FROM `*PREFIX*news_items`'; return $this->execute($sql, [], $limit, $offset)->fetchAll(); } @@ -361,7 +358,7 @@ class ItemMapper extends NewsMapper { // stop condition if there are no previously fetched items while ($itemCount > 0) { - $items = $this->findAllItemIdsAndUsers($step, $offset); + $items = $this->findAllIds($step, $offset); $itemCount = count($items); $this->updateSearchIndex($items); $offset += $step; @@ -370,15 +367,15 @@ class ItemMapper extends NewsMapper { private function updateSearchIndex(array $items=[]) { foreach ($items as $row) { - // ignore items of deleted rows try { - $item = $this->find($row['id'], $row['user_id']); - } catch(\Exception $e) { + $sql = 'SELECT * FROM `*PREFIX*news_items` WHERE `id` = ?'; + $params = [$row['id']]; + $item = $this->findEntity($sql, $params); + $item->generateSearchIndex(); + $this->update($item); + } catch (Exception $e) { continue; } - - $item->generateSearchIndex(); - $this->update($item); } } |