mirror of
https://github.com/friendica/friendica
synced 2025-04-25 03:10:11 +00:00
Use the post-counts table to display content (#13781)
* Use the post-counts table to display content * Use verb instead of vid * Use verb * Update counter on delete
This commit is contained in:
parent
0c68a53e1e
commit
8fc96477e7
12 changed files with 250 additions and 126 deletions
|
@ -41,7 +41,9 @@ use Friendica\Database\DBA;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Post\Engagement;
|
||||
use Friendica\Model\Verb;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -626,6 +628,8 @@ class Timeline extends BaseModule
|
|||
$result = Post::selectThreadForUser($this->session->getLocalUserId() ?: 0, ['uri-id', 'received', 'author-id', 'author-gsid'], $condition, $params);
|
||||
|
||||
while ($item = $this->database->fetch($result)) {
|
||||
$item['comments'] = 0;
|
||||
|
||||
$items[$item['uri-id']] = $item;
|
||||
}
|
||||
$this->database->close($result);
|
||||
|
@ -634,6 +638,12 @@ class Timeline extends BaseModule
|
|||
return [];
|
||||
}
|
||||
|
||||
$uriids = array_keys($items);
|
||||
|
||||
foreach (Post\Counts::get(['parent-uri-id' => $uriids, 'verb' => Activity::POST]) as $count) {
|
||||
$items[$count['parent-uri-id']]['comments'] += $count['count'];
|
||||
}
|
||||
|
||||
// Previous page case: once we get the relevant items closest to min_id, we need to restore the expected display order
|
||||
if (empty($this->itemUriId) && isset($this->minId) && !isset($this->maxId)) {
|
||||
$items = array_reverse($items);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue