fix: q=category lists only tags on existing posts (v2.12.1)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13936749de
commit
b450c0c648
7 files changed
+60
-7
No files matched your search
@@ -457,5 +457,5 @@ def create_app(config=None):
|
||||
|
||||
# Package version (Semantic Versioning 2.0.0)
|
||||
# See docs/standards/versioning-strategy.md for details
|
||||
__version__ = "2.12.0"
|
||||
__version_info__ = (2, 12, 0)
|
||||
__version__ = "2.12.1"
|
||||
__version_info__ = (2, 12, 1)
|
||||
@@ -842,13 +842,16 @@ def note_to_mf2(note, wanted: Optional[list] = None) -> dict:
|
||||
|
||||
|
||||
def _all_categories(prefix: str = "") -> list:
|
||||
"""Tags in use, most used first (q=category)"""
|
||||
"""Tags on posts that exist (drafts included), most used first (q=category)"""
|
||||
from starpunk.database import get_db
|
||||
|
||||
# Inner joins: tags left behind by edits or soft-deleted posts don't count
|
||||
rows = get_db(current_app).execute(
|
||||
"""
|
||||
SELECT t.display_name, COUNT(nt.note_id) AS uses
|
||||
FROM tags t LEFT JOIN note_tags nt ON nt.tag_id = t.id
|
||||
SELECT t.display_name, COUNT(*) AS uses
|
||||
FROM tags t
|
||||
JOIN note_tags nt ON nt.tag_id = t.id
|
||||
JOIN notes n ON n.id = nt.note_id AND n.deleted_at IS NULL
|
||||
GROUP BY t.id ORDER BY uses DESC, t.display_name
|
||||
"""
|
||||
).fetchall()
|
||||
|
||||
Reference in new issue
Block a user