Centralized functionality to store and delete the check-full-text-search table

This commit is contained in:
Michael 2024-01-15 22:28:42 +00:00
parent 23b247d1c3
commit 63b958dcc6

View File

@ -189,9 +189,10 @@ class UserDefinedChannel extends \Friendica\BaseRepository
$search .= '(' . $channel->fullTextSearch . ') '; $search .= '(' . $channel->fullTextSearch . ') ';
} }
$this->db->insert('check-full-text-search', ['pid' => getmypid(), 'searchtext' => $searchtext], Database::INSERT_UPDATE); $this->insertCheckFullTextSearch($searchtext);
$result = $this->inFulltext($search); $result = $this->inFulltext($search);
$this->db->delete('check-full-text-search', ['pid' => getmypid()]); $this->deleteCheckFullTextSearch();
return $result; return $result;
} }
@ -220,7 +221,7 @@ class UserDefinedChannel extends \Friendica\BaseRepository
return []; return [];
} }
$this->db->insert('check-full-text-search', ['pid' => getmypid(), 'searchtext' => $searchtext], Database::INSERT_UPDATE); $this->insertCheckFullTextSearch($searchtext);
$uids = []; $uids = [];
@ -264,10 +265,20 @@ class UserDefinedChannel extends \Friendica\BaseRepository
$this->logger->debug('Matching channel found.', ['uid' => $channel->uid, 'label' => $channel->label, 'language' => $language, 'tags' => $tags, 'media_type' => $media_type, 'searchtext' => $searchtext]); $this->logger->debug('Matching channel found.', ['uid' => $channel->uid, 'label' => $channel->label, 'language' => $language, 'tags' => $tags, 'media_type' => $media_type, 'searchtext' => $searchtext]);
} }
$this->db->delete('check-full-text-search', ['pid' => getmypid()]); $this->deleteCheckFullTextSearch();
return $uids; return $uids;
} }
private function insertCheckFullTextSearch(string $searchtext)
{
$this->db->insert('check-full-text-search', ['pid' => getmypid(), 'searchtext' => $searchtext], Database::INSERT_UPDATE);
}
private function deleteCheckFullTextSearch()
{
$this->db->delete('check-full-text-search', ['pid' => getmypid()]);
}
private function inCircle(int $circleId, int $uid, int $cid): bool private function inCircle(int $circleId, int $uid, int $cid): bool
{ {
if ($cid == 0) { if ($cid == 0) {