Handle tag filtering in the Bookmark service

This commit is contained in:
ArthurHoaro 2020-05-16 13:13:00 +02:00
parent 72caf4e84c
commit c79473bd84
5 changed files with 3 additions and 15 deletions

View file

@ -296,6 +296,7 @@ public function bookmarksCountPerTag($filteringTags = [], $visibility = null)
if (empty($tag)
|| (! $this->isLoggedIn && startsWith($tag, '.'))
|| $tag === BookmarkMarkdownFormatter::NO_MD_TAG
|| in_array($tag, $filteringTags, true)
) {
continue;
}

View file

@ -39,9 +39,6 @@ public function index(Request $request, Response $response): Response
$logMaxCount = $maxCount > 1 ? log($maxCount, 30) : 1;
$tagList = [];
foreach ($tags as $key => $value) {
if (in_array($key, $filteringTags)) {
continue;
}
// Tag font size scaling:
// default 15 and 30 logarithm bases affect scaling,
// 2.2 and 0.8 are arbitrary font sizes in em.

View file

@ -625,11 +625,6 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
$visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
$filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : [];
$tags = $bookmarkService->bookmarksCountPerTag($filteringTags, $visibility);
foreach ($filteringTags as $tag) {
if (array_key_exists($tag, $tags)) {
unset($tags[$tag]);
}
}
if (! empty($_GET['sort']) && $_GET['sort'] === 'alpha') {
alphabetical_sort($tags, false, true);

View file

@ -816,7 +816,6 @@ public function testAllTags()
);
$this->assertEquals(
[
'web' => 4,
'cartoon' => 2,
'gnu' => 1,
'dev' => 1,
@ -833,7 +832,6 @@ public function testAllTags()
);
$this->assertEquals(
[
'web' => 1,
'html' => 1,
'w3c' => 1,
'css' => 1,
@ -968,7 +966,6 @@ public function testCountLinkPerTagAllNoFilter()
public function testCountLinkPerTagAllWithFilter()
{
$expected = [
'gnu' => 2,
'hashtag' => 2,
'-exclude' => 1,
'.hidden' => 1,
@ -991,7 +988,6 @@ public function testCountLinkPerTagAllWithFilter()
public function testCountLinkPerTagPublicWithFilter()
{
$expected = [
'gnu' => 2,
'hashtag' => 2,
'-exclude' => 1,
'.hidden' => 1,
@ -1015,7 +1011,6 @@ public function testCountLinkPerTagPrivateWithFilter()
{
$expected = [
'cartoon' => 1,
'dev' => 1,
'tag1' => 1,
'tag2' => 1,
'tag3' => 1,

View file

@ -127,8 +127,8 @@ public function testValidCloudControllerInvokeWithParameters(): void
->expects(static::once())
->method('bookmarksCountPerTag')
->with(['ghi', 'def'], BookmarkFilter::$PRIVATE)
->willReturnCallback(function () use ($allTags): array {
return $allTags;
->willReturnCallback(function (): array {
return ['abc' => 3];
})
;