[CORE] Re-format the inboxnoticestream query

This commit is contained in:
Alexei Sorokin 2020-04-08 15:25:30 +03:00 committed by Diogo Peralta Cordeiro
parent 4caa394db6
commit 9396539f58

View File

@ -92,12 +92,20 @@ class RawInboxNoticeStream extends FullNoticeStream
// Reply:: is a table of mentions // Reply:: is a table of mentions
// Subscription:: is a table of subscriptions (every user is subscribed to themselves) // Subscription:: is a table of subscriptions (every user is subscribed to themselves)
$notice->_join .= sprintf( $notice->_join .= sprintf(
"\n" . 'NATURAL INNER JOIN (' . "\n" . <<<'END'
'(SELECT id FROM notice WHERE profile_id IN (SELECT subscribed FROM subscription WHERE subscriber = %1$d)) ' . INNER JOIN (
'UNION (SELECT notice_id AS id FROM reply WHERE profile_id = %1$d) ' . (SELECT id FROM notice
'UNION (SELECT notice_id AS id FROM attention WHERE profile_id = %1$d) ' . WHERE profile_id
'UNION (SELECT notice_id AS id FROM group_inbox WHERE group_id IN (SELECT group_id FROM group_member WHERE profile_id = %1$d))' . IN (SELECT subscribed FROM subscription WHERE subscriber = %1$d))
') AS t1', UNION
(SELECT notice_id AS id FROM reply WHERE profile_id = %1$d)
UNION
(SELECT notice_id AS id FROM attention WHERE profile_id = %1$d)
UNION
(SELECT notice_id AS id FROM group_inbox INNER JOIN group_member USING (group_id)
WHERE group_member.profile_id = %1$d)
) AS t1 USING (id)
END,
$this->target->getID() $this->target->getID()
); );