Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
  • Loading branch information
Grotax committed Nov 18, 2021
1 parent fbacf4c commit f0a1c92
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 38 deletions.
2 changes: 1 addition & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* [Robin Appelman](mailto:icewind@owncloud.com)
* [Sean Molenaar](mailto:sean@seanmolenaar.eu)
* [Gregor Tätzner](mailto:gregor@freenet.de)
* [anoy](mailto:anoymouserver+github@mailbox.org)
* [Sean Molenaar](mailto:SMillerDev@users.noreply.github.com)
* [anoy](mailto:anoymouserver+github@mailbox.org)
* [Morris Jobke](mailto:hey@morrisjobke.de)
* [Jimmy Huynh](mailto:jimmy.huynh@etu.unistra.fr)
* [Aurélien](mailto:dav.aurelien@gmail.com)
Expand Down
70 changes: 38 additions & 32 deletions lib/Db/FeedMapperV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ public function findAllFromUser(string $userId, array $params = []): array
{
$builder = $this->db->getQueryBuilder();
$builder->select('feeds.*', $builder->func()->count('items.id', 'unreadCount'))
->from(static::TABLE_NAME, 'feeds')
->leftJoin(
'feeds',
ItemMapperV2::TABLE_NAME,
'items',
'items.feed_id = feeds.id AND items.unread = :unread'
)
->where('feeds.user_id = :user_id')
->andWhere('feeds.deleted_at = 0')
->groupBy('feeds.id')
->setParameter('unread', true, IQueryBuilder::PARAM_BOOL)
->setParameter('user_id', $userId);
->from(static::TABLE_NAME, 'feeds')
->leftJoin(
'feeds',
ItemMapperV2::TABLE_NAME,
'items',
'items.feed_id = feeds.id AND items.unread = :unread'
)
->where('feeds.user_id = :user_id')
->andWhere('feeds.deleted_at = 0')
->groupBy('feeds.id')
->setParameter('unread', true, IQueryBuilder::PARAM_BOOL)
->setParameter('user_id', $userId);

return $this->findEntities($builder);
}
Expand All @@ -84,11 +84,11 @@ public function findFromUser(string $userId, int $id): Entity
{
$builder = $this->db->getQueryBuilder();
$builder->select('*')
->from(static::TABLE_NAME)
->where('user_id = :user_id')
->andWhere('id = :id')
->setParameter('user_id', $userId)
->setParameter('id', $id);
->from(static::TABLE_NAME)
->where('user_id = :user_id')
->andWhere('id = :id')
->setParameter('user_id', $userId)
->setParameter('id', $id);

return $this->findEntity($builder);
}
Expand All @@ -102,8 +102,8 @@ public function findAll(): array
{
$builder = $this->db->getQueryBuilder();
$builder->select('*')
->from(static::TABLE_NAME)
->where('deleted_at = 0');
->from(static::TABLE_NAME)
->where('deleted_at = 0');

return $this->findEntities($builder);
}
Expand All @@ -123,11 +123,11 @@ public function findByURL(string $userId, string $url): Entity
{
$builder = $this->db->getQueryBuilder();
$builder->select('*')
->from(static::TABLE_NAME)
->where('user_id = :user_id')
->andWhere('url = :url')
->setParameter('user_id', $userId)
->setParameter('url', $url);
->from(static::TABLE_NAME)
->where('user_id = :user_id')
->andWhere('url = :url')
->setParameter('user_id', $userId)
->setParameter('url', $url);

return $this->findEntity($builder);
}
Expand All @@ -143,13 +143,13 @@ public function findAllFromFolder(?int $id): array
{
$builder = $this->db->getQueryBuilder();
$builder->select('*')
->from(static::TABLE_NAME);
->from(static::TABLE_NAME);

if (is_null($id)) {
$builder->where('folder_id IS NULL');
} else {
$builder->where('folder_id = :folder_id')
->setParameter('folder_id', $id);
->setParameter('folder_id', $id);
}

return $this->findEntities($builder);
Expand All @@ -163,7 +163,6 @@ public function findAllFromFolder(?int $id): array
* @return int
* @throws DBException
*
* @TODO Update for NC 21
*/
public function read(string $userId, int $id, ?int $maxItemID = null): int
{
Expand All @@ -178,12 +177,15 @@ public function read(string $userId, int $id, ?int $maxItemID = null): int

if ($maxItemID !== null) {
$idBuilder->andWhere('items.id <= :maxItemId')
->setParameter('maxItemId', $maxItemID);
->setParameter('maxItemId', $maxItemID);
}

$idList = array_map(function ($value): int {
return intval($value['id']);
}, $this->db->executeQuery($idBuilder->getSQL(), $idBuilder->getParameters())->fetchAll());
$idList = array_map(
function ($value): int {
return intval($value['id']);
},
$this->db->executeQuery($idBuilder->getSQL(), $idBuilder->getParameters())->fetchAll()
);

$builder = $this->db->getQueryBuilder();
$builder->update(ItemMapperV2::TABLE_NAME)
Expand All @@ -193,6 +195,10 @@ public function read(string $userId, int $id, ?int $maxItemID = null): int
->setParameter('unread', false, IQueryBuilder::PARAM_BOOL)
->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY);

return $this->db->executeStatement($builder->getSQL(), $builder->getParameters(), $builder->getParameterTypes());
return $this->db->executeStatement(
$builder->getSQL(),
$builder->getParameters(),
$builder->getParameterTypes()
);
}
}
8 changes: 6 additions & 2 deletions lib/Db/FolderMapperV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function findFromUser(string $userId, int $id): Entity
* @return int
*
* @throws DBException
* @TODO Update for NC 21
*
*/
public function read(string $userId, int $id, ?int $maxItemID = null): int
{
Expand Down Expand Up @@ -136,6 +136,10 @@ public function read(string $userId, int $id, ?int $maxItemID = null): int
->setParameter('unread', false, IQueryBuilder::PARAM_BOOL)
->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY);

return $this->db->executeStatement($builder->getSQL(), $builder->getParameters(), $builder->getParameterTypes());
return $this->db->executeStatement(
$builder->getSQL(),
$builder->getParameters(),
$builder->getParameterTypes()
);
}
}
8 changes: 5 additions & 3 deletions lib/Db/ItemMapperV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ public function purgeDeleted(?string $userID, ?int $oldestDelete): void
* @param string $userId
* @param int $maxItemId
*
* @TODO: Update this for NC 21
*
* @return int
*
* @throws DBException
Expand Down Expand Up @@ -282,7 +280,11 @@ public function readAll(string $userId, int $maxItemId): int
->setParameter('unread', false, IQueryBuilder::PARAM_BOOL)
->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY);

return $this->db->executeStatement($builder->getSQL(), $builder->getParameters(), $builder->getParameterTypes());
return $this->db->executeStatement(
$builder->getSQL(),
$builder->getParameters(),
$builder->getParameterTypes()
);
}

/**
Expand Down

0 comments on commit f0a1c92

Please sign in to comment.