Ignore bookmarked empty groups for total count

This commit is contained in:
itismadness
2025-09-08 21:04:29 +00:00
committed by Spine
parent 9d317538b7
commit a065d7ed0a
3 changed files with 9 additions and 6 deletions

View File

@@ -249,9 +249,10 @@ class Bookmark extends \Gazelle\BaseUser {
public function tgroupTotal(): int {
return (int)self::$db->scalar("
SELECT count(*)
FROM bookmarks_torrents
WHERE UserID = ?
SELECT count(DISTINCT b.GroupID)
FROM bookmarks_torrents b
INNER JOIN torrents t USING (GroupID)
WHERE b.UserID = ?
", $this->id
);
}

View File

@@ -34,12 +34,13 @@ $reportMan = new Manager\Report($userMan);
$tgMan = new Manager\TGroup();
$torMan = new Manager\Torrent();
$collMan = new Manager\Collage()->setImageProxy(new Util\ImageProxy($Viewer));
$NumGroups = $bookmark->tgroupTotal();
$totalGroups = $bookmark->tgroupTotal();
$paginator = new Util\Paginator(200, (int)($_GET['page'] ?? 1));
$paginator->setTotal($NumGroups);
$paginator->setTotal($totalGroups);
$bookmarkList = $bookmark->tgroupList($paginator->limit(), $paginator->offset());
$NumGroups = count($bookmarkList);
$artistLeaderboard = $bookmark->tgroupArtistLeaderboard();
$tagLeaderboard = $bookmark->tgroupTagLeaderboard();
$CollageCovers = (int)($Viewer->option('CollageCovers') ?? 25);
@@ -89,7 +90,7 @@ if (count($bookmarkList) === 0) { ?>
<div class="box box_info box_statistics_bookmarked_torrents">
<div class="head"><strong>Stats</strong></div>
<ul class="stats nobullet">
<li>Torrent groups: <?=$NumGroups?></li>
<li>Torrent groups: <?= $totalGroups ?></li>
<li>Artists: <?= $bookmark->tgroupArtistTotal() ?></li>
</ul>
</div>

View File

@@ -599,6 +599,7 @@ class TGroupTest extends TestCase {
$bookmarker->isBookmarked($this->tgroup),
'tgroup-merge-bookmark',
);
$this->assertEquals(1, $bookmarker->tgroupTotal(), 'tgroup-bookmark-tgroupTotal');
$list = $bookmarker->tgroupBookmarkList();
$this->assertCount(1, $list, 'tgroup-bookmark-user-total');
$this->assertEquals(