Skip to content

Commit

Permalink
🐛 fix: Correct tag count query by joining content_tags_mapping table
Browse files Browse the repository at this point in the history
- Fixed the tag count query to accurately count tags by joining the `content_tags_mapping` table
- Updated both SQL query and generated Go code to reflect the change
  • Loading branch information
vaayne committed Jan 6, 2025
1 parent 5ac5003 commit 844d2da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion database/queries/content.sql
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ WHERE id = $1
AND user_id = $3;

-- name: ListTagsByUser :many
SELECT ct.name, count(*) as count
SELECT ct.name, count(ctm.*) as count
FROM content_tags ct
JOIN content_tags_mapping ctm ON ct.id = ctm.tag_id
WHERE ct.user_id = $1
GROUP BY ct.name
ORDER BY count DESC;
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/db/content.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 844d2da

Please sign in to comment.