mirror of
https://github.com/friendica/friendica
synced 2025-04-25 21:10:11 +00:00
Reduce the amount of queries
This commit is contained in:
parent
aa65e3032d
commit
1326239576
2 changed files with 21 additions and 17 deletions
|
@ -108,6 +108,8 @@ class Conversation
|
|||
*/
|
||||
public function builtinActivityPuller(array $activity, array &$conv_responses)
|
||||
{
|
||||
$thread_parent = $activity['thr-parent-row'] ?? [];
|
||||
|
||||
foreach ($conv_responses as $mode => $v) {
|
||||
$sparkle = '';
|
||||
|
||||
|
@ -152,9 +154,8 @@ class Conversation
|
|||
$activity['thr-parent-id'] = $activity['parent-uri-id'];
|
||||
}
|
||||
|
||||
// Skip when the causer of the parent is the same than the author of the announce
|
||||
if (($verb == Activity::ANNOUNCE) && Post::exists(['uri-id' => $activity['thr-parent-id'],
|
||||
'uid' => $activity['uid'], 'causer-id' => $activity['author-id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]])) {
|
||||
// Skip when the causer of the parent is the same as the author of the announce
|
||||
if (($verb == Activity::ANNOUNCE) && !empty($thread_parent['causer-id'] && ($thread_parent['causer-id'] == $activity['author-id']))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -809,12 +810,13 @@ class Conversation
|
|||
/**
|
||||
* Adds some information (Causer, post reason, direction) to the fetched post row.
|
||||
*
|
||||
* @param array $row Post row
|
||||
* @param array $activity Contact data of the resharer
|
||||
* @param array $row Post row
|
||||
* @param array $activity Contact data of the resharer
|
||||
* @param array $thr_parent Thread parent row
|
||||
*
|
||||
* @return array items with parents and comments
|
||||
*/
|
||||
private function addRowInformation(array $row, array $activity)
|
||||
private function addRowInformation(array $row, array $activity, array $thr_parent)
|
||||
{
|
||||
$this->profiler->startRecording('rendering');
|
||||
|
||||
|
@ -889,6 +891,8 @@ class Conversation
|
|||
break;
|
||||
}
|
||||
|
||||
$row['thr-parent-row'] = $thr_parent;
|
||||
|
||||
$this->profiler->stopRecording();
|
||||
return $row;
|
||||
}
|
||||
|
@ -954,6 +958,7 @@ class Conversation
|
|||
$thread_items = Post::selectForUser($uid, array_merge(ItemModel::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), $condition, $params);
|
||||
|
||||
$items = [];
|
||||
$thr_parent = [];
|
||||
|
||||
while ($row = Post::fetch($thread_items)) {
|
||||
if (!empty($items[$row['uri-id']]) && ($row['uid'] == 0)) {
|
||||
|
@ -968,7 +973,12 @@ class Conversation
|
|||
continue;
|
||||
}
|
||||
}
|
||||
$items[$row['uri-id']] = $this->addRowInformation($row, $activities[$row['uri-id']] ?? []);
|
||||
|
||||
if (empty($thr_parent[$row['thr-parent-id']])) {
|
||||
$thr_parent[$row['thr-parent-id']] = Post::selectFirst(['causer-id'], ['uri-id' => $row['thr-parent-id'], 'uid' => $row['uid']]);
|
||||
}
|
||||
|
||||
$items[$row['uri-id']] = $this->addRowInformation($row, $activities[$row['uri-id']] ?? [], $thr_parent[$row['thr-parent-id']]);
|
||||
}
|
||||
|
||||
DBA::close($thread_items);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue