Skip to content

Commit

Permalink
[ouroboros] remove hard dependency on tag map
Browse files Browse the repository at this point in the history
  • Loading branch information
socram8888 committed Dec 30, 2024
1 parent ae86f08 commit 590474f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ext/ouroboros_api/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,13 @@ protected function postIndex(int $limit, int $page, array $tags): void
protected function tagIndex(int $limit, int $page, string $order, string $name, string $name_pattern): void
{
global $database, $config;

// This class will only exist if the tag map plugin is enabled
$tags_min = 0;
if (class_exists('\Shimmie2\TagMapConfig')) {
$tags_min = $config->get_int(TagMapConfig::TAGS_MIN);
}

$start = ($page - 1) * $limit;
switch ($order) {
case 'name':
Expand All @@ -432,7 +439,7 @@ protected function tagIndex(int $limit, int $page, string $order, string $name,
WHERE count >= :tags_min
ORDER BY LOWER(substr(tag, 1, 1)) LIMIT :start, :max_items
",
['tags_min' => $config->get_int(TagMapConfig::TAGS_MIN), 'start' => $start, 'max_items' => $limit]
['tags_min' => $tags_min, 'start' => $start, 'max_items' => $limit]
);
break;
case 'count':
Expand All @@ -444,7 +451,7 @@ protected function tagIndex(int $limit, int $page, string $order, string $name,
WHERE count >= :tags_min
ORDER BY count DESC, tag ASC LIMIT :start, :max_items
",
['tags_min' => $config->get_int(TagMapConfig::TAGS_MIN), 'start' => $start, 'max_items' => $limit]
['tags_min' => $tags_min, 'start' => $start, 'max_items' => $limit]
);
break;
}
Expand Down

0 comments on commit 590474f

Please sign in to comment.