-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include annotation tags for /collections/:key/tags #163
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
model/Collection.inc.php
Outdated
JOIN itemAnnotations USING (itemID) | ||
JOIN itemAttachments ON itemAttachments.itemID = itemAnnotations.parentItemID | ||
JOIN collectionItems ON collectionItems.itemID = itemAttachments.sourceItemID | ||
WHERE collectionID=? GROUP BY tagID;"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No semicolon needed
model/Collection.inc.php
Outdated
$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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
House style: parens around the expression for consistency with USING
, even though it's not required for ON
model/Collection.inc.php
Outdated
@@ -629,6 +629,24 @@ public function getTagItemCounts() { | |||
foreach ($rows as $row) { | |||
$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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
numItems
field. So, if tagA
belongs to an annotation of an attachment, and the attachment itself has tagA
,numItems
will be 2.Fixes: #162