diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2020-12-26 13:09:41 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2020-12-30 11:21:44 +0100 |
commit | 05377d023ef4d43818a4b42039c8143cb0f907e4 (patch) | |
tree | c01fc681c42671dad774de7dc7c46524eb9ae015 /lib/Service/ItemServiceV2.php | |
parent | 27bd54058050a70bd1c9ec8cfcdf42d38541f1b0 (diff) |
Remove PHPunit integration tests
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Service/ItemServiceV2.php')
-rw-r--r-- | lib/Service/ItemServiceV2.php | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/Service/ItemServiceV2.php b/lib/Service/ItemServiceV2.php index 0a04fd8ad..54cefa197 100644 --- a/lib/Service/ItemServiceV2.php +++ b/lib/Service/ItemServiceV2.php @@ -16,6 +16,7 @@ use OCA\News\AppInfo\Application; use OCA\News\Db\Item; use OCA\News\Db\ItemMapperV2; use OCP\AppFramework\Db\DoesNotExistException; +use OCP\AppFramework\Db\Entity; use OCP\IConfig; use Psr\Log\LoggerInterface; @@ -76,8 +77,10 @@ class ItemServiceV2 extends Service * Insert an item or update. * * @param Item $item + * + * @return Entity|Item The updated/inserted item */ - public function insertOrUpdate(Item $item) + public function insertOrUpdate(Item $item): Entity { try { $db_item = $this->mapper->findByGuidHash($item->getFeedId(), $item->getGuidHash()); @@ -94,17 +97,24 @@ class ItemServiceV2 extends Service $item->resetUpdatedFields(); } - $this->mapper->update($item); + return $this->mapper->update($item); } catch (DoesNotExistException $exception) { - $this->mapper->insert($item); + return $this->mapper->insert($item); } } + /** + * @param int $feedId + * + * @return array + */ public function findAllForFeed(int $feedId): array { return $this->mapper->findAllForFeed($feedId); } + + public function purgeOverThreshold(int $threshold = null) { @@ -120,4 +130,13 @@ class ItemServiceV2 extends Service return $this->mapper->deleteOverThreshold($threshold); } + + /** + * @param int $feedId + * @param string $guidHash + */ + public function findForGuidHash(int $feedId, string $guidHash) + { + return $this->mapper->findByGuidHash($feedId, $guidHash); + } } |