inboxnoticestream.php gotta go fast

This commit is contained in:
Diogo Cordeiro 2019-04-23 23:10:43 +01:00
parent fc4aa470b2
commit 5dcc98d1c6

View File

@ -5,8 +5,6 @@
* *
* Stream of notices for a profile's "all" feed * Stream of notices for a profile's "all" feed
* *
* PHP version 5
*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by * it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
@ -138,6 +136,14 @@ class RawInboxNoticeStream extends FullNoticeStream
); );
$notice_ids += $group_inbox->fetchAll('notice_id'); $notice_ids += $group_inbox->fetchAll('notice_id');
// This is just to make the query lighter when processed by the Database server
$notice_ids = array_filter($notice_ids, function ($id) {
// Keep id (a.k.a.: return true) if:
// - id higher than since id (just constrain if specified)
// - id lower than max id (just constrain if specified)
return (empty($since_id) || $id > $since_id) && (empty($max_id) || $id <= $max_id);
});
$query_ids = ''; $query_ids = '';
if (!empty($notice_ids)) { // Replies, Attentions and Groups if (!empty($notice_ids)) { // Replies, Attentions and Groups