include annotation tags for /collections/:key/tags#163
Conversation
There was a problem hiding this comment.
This will cause tags to be returned, but those tags won't actually match any top-level items (e.g., when clicked in the tag selector, which this is for), so I think we'll need to update Items::search() as well, and that's where the itemTopLevel stuff comes in.
| JOIN itemAnnotations USING (itemID) | ||
| JOIN itemAttachments ON itemAttachments.itemID = itemAnnotations.parentItemID | ||
| JOIN collectionItems ON collectionItems.itemID = itemAttachments.sourceItemID | ||
| WHERE collectionID=? GROUP BY tagID;"; |
| $annotationsSql = "SELECT tagID, COUNT(*) AS numItems FROM tags JOIN itemTags USING (tagID) | ||
| JOIN itemAnnotations USING (itemID) | ||
| JOIN itemAttachments ON itemAttachments.itemID = itemAnnotations.parentItemID | ||
| JOIN collectionItems ON collectionItems.itemID = itemAttachments.sourceItemID |
There was a problem hiding this comment.
House style: parens around the expression for consistency with USING, even though it's not required for ON
| $counts[$row['tagID']] = $row['numItems']; | ||
| } | ||
| // Fetch the tags of annotations as well | ||
| $annotationsSql = "SELECT tagID, COUNT(*) AS numItems FROM tags JOIN itemTags USING (tagID) |
There was a problem hiding this comment.
JOIN on next line, but I guess we technically don't need tags here or above, so could just remove that.
|
I see. Now the annotation tags are returned but if we, say, hit |
In Zoteri_Items::search, if /top items are requested, fetch the top item's itemID during tag filtering as opposed to the actual item's itemID. That way, if an attachment has a tag, the top level attachment would be matches on that tag search query.
|
When in It will do the same for other children like notes or attachments - do we want it? The web library calls If we want to keep filtering by all children's tags in |
Tags for annotations are counted just like items in
numItemsfield. So, if tagAbelongs to an annotation of an attachment, and the attachment itself has tagA,numItemswill be 2.Fixes: #162