diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-11-30 10:02:25 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2018-11-30 10:02:25 -0100 |
commit | 75447af7671b9e45d3f5db0ba75bbfcd6a0318a3 (patch) | |
tree | 918ca0f86c3629499ca363080668dc115644ecb5 /lib/Db | |
parent | 8b9ca910ba3b0fa7e33c664689954413f0430700 (diff) | |
parent | 011074646a68e7d80ff1edccbe627f06d4b401f6 (diff) |
Merge remote-tracking branch 'origin/more-for-local-accounts' into more-for-local-accounts
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Db')
-rw-r--r-- | lib/Db/CacheActorsRequest.php | 26 | ||||
-rw-r--r-- | lib/Db/FollowsRequestBuilder.php | 16 |
2 files changed, 42 insertions, 0 deletions
diff --git a/lib/Db/CacheActorsRequest.php b/lib/Db/CacheActorsRequest.php index 85c4a2e8..1be44384 100644 --- a/lib/Db/CacheActorsRequest.php +++ b/lib/Db/CacheActorsRequest.php @@ -202,6 +202,32 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { /** + * get Cached version of a local Actor, based on the preferred username + * + * @param string $account + * + * @return Person + * @throws CacheActorDoesNotExistException + */ + public function getFromLocalAccount(string $account): Person { + $qb = $this->getCacheActorsSelectSql(); + $this->limitToPreferredUsername($qb, $account); + $this->limitToLocal($qb, true); + $this->leftJoinCacheDocuments($qb, 'icon_id'); + + $cursor = $qb->execute(); + $data = $cursor->fetch(); + $cursor->closeCursor(); + + if ($data === false) { + throw new CacheActorDoesNotExistException(); + } + + return $this->parseCacheActorsSelectSql($data); + } + + + /** * @param string $search * @param string $viewerId * diff --git a/lib/Db/FollowsRequestBuilder.php b/lib/Db/FollowsRequestBuilder.php index 0f50b37e..3a1d9445 100644 --- a/lib/Db/FollowsRequestBuilder.php +++ b/lib/Db/FollowsRequestBuilder.php @@ -109,6 +109,22 @@ class FollowsRequestBuilder extends CoreRequestBuilder { /** + * Base of the Sql Select request for Shares + * + * @return IQueryBuilder + */ + protected function countFollowsSelectSql(): IQueryBuilder { + $qb = $this->dbConnection->getQueryBuilder(); + $qb->selectAlias($qb->createFunction('COUNT(*)'), 'count') + ->from(self::TABLE_SERVER_FOLLOWS, 'f'); + + $this->defaultSelectAlias = 'f'; + + return $qb; + } + + + /** * Base of the Sql Delete request * * @return IQueryBuilder |