kopia lustrzana https://github.com/nextcloud/social
getStreamHome on sqlite
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/143/head
rodzic
554213c391
commit
33931508dd
|
|
@ -169,11 +169,7 @@ class NotesRequest extends NotesRequestBuilder {
|
|||
public function getStreamHome(string $actorId, int $since = 0, int $limit = 5): array {
|
||||
$qb = $this->getNotesSelectSql();
|
||||
|
||||
$this->rightJoinFollowing($qb);
|
||||
$this->limitToActorId($qb, $actorId, 'f');
|
||||
$this->limitToAccepted($qb, true, 'f');
|
||||
$qb->orWhere($this->exprLimitToDBField($qb, 'attributed_to', $actorId));
|
||||
|
||||
$this->rightJoinFollowing($qb, $actorId);
|
||||
$this->limitPaginate($qb, $since, $limit);
|
||||
$this->leftJoinCacheActors($qb, 'attributed_to');
|
||||
|
||||
|
|
|
|||
|
|
@ -124,8 +124,9 @@ class NotesRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $actorId
|
||||
*/
|
||||
protected function rightJoinFollowing(IQueryBuilder $qb) {
|
||||
protected function rightJoinFollowing(IQueryBuilder $qb, string $actorId = '') {
|
||||
if ($qb->getType() !== QueryBuilder::SELECT) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -135,8 +136,14 @@ class NotesRequestBuilder extends CoreRequestBuilder {
|
|||
$pf = $this->defaultSelectAlias . '.';
|
||||
|
||||
$orX = $expr->orX();
|
||||
$orX->add($expr->eq($func->lower($pf . 'to'), $func->lower('f.follow_id')));
|
||||
$orX->add(
|
||||
if ($actorId !== '') {
|
||||
$orX->add($this->exprLimitToDBField($qb, 'attributed_to', $actorId, false));
|
||||
}
|
||||
|
||||
// list of possible follow (to, to_array, cc, ...)
|
||||
$orXFollow = $expr->orX();
|
||||
$orXFollow->add($expr->eq($func->lower($pf . 'to'), $func->lower('f.follow_id')));
|
||||
$orXFollow->add(
|
||||
$expr->like(
|
||||
$func->lower($pf . 'to_array'), $func->concat(
|
||||
$qb->createNamedParameter('%"'),
|
||||
|
|
@ -144,7 +151,7 @@ class NotesRequestBuilder extends CoreRequestBuilder {
|
|||
)
|
||||
)
|
||||
);
|
||||
$orX->add(
|
||||
$orXFollow->add(
|
||||
$expr->like(
|
||||
$func->lower($pf . 'cc'), $func->concat(
|
||||
$qb->createNamedParameter('%"'),
|
||||
|
|
@ -152,7 +159,7 @@ class NotesRequestBuilder extends CoreRequestBuilder {
|
|||
)
|
||||
)
|
||||
);
|
||||
$orX->add(
|
||||
$orXFollow->add(
|
||||
$expr->like(
|
||||
$func->lower($pf . 'bcc'), $func->concat(
|
||||
$qb->createNamedParameter('%"'),
|
||||
|
|
@ -161,6 +168,14 @@ class NotesRequestBuilder extends CoreRequestBuilder {
|
|||
)
|
||||
);
|
||||
|
||||
// all possible follow, but linked by followers (actor_id) and accepted follow
|
||||
$andXFollow = $expr->andX();
|
||||
$andXFollow->add($orXFollow);
|
||||
$andXFollow->add($this->exprLimitToDBField($qb, 'actor_id', $actorId, false, 'f'));
|
||||
$andXFollow->add($this->exprLimitToDBFieldInt($qb, 'accepted', 1, 'f'));
|
||||
|
||||
$orX->add($andXFollow);
|
||||
|
||||
// TODO: SQLite does not support RIGHT JOIN
|
||||
// $qb->rightJoin(
|
||||
$qb->join(
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue