-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
SystemTags endpoint to return tags used by a user with meta data #37961
Conversation
543a891
to
c174172
Compare
Added support for media types and updated the information in the summary. Compared to the first commit, it's a little breaking, for filtering image files was hardcoded. To achive the same results run the query against |
Can we call the endpoint something more meaningful than systemtags-current? |
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.
fine by me except other peoples comments of course. And would also love to have this in for 27 even if we might optimize further in the future or have a complete new solution for certain things regarding tags.
Also, given the time I think Beta2 would be fine.
We can, but do you have suggestions? Tbh, I am not super happy about it either, but was so far the best I could think of:
And i disregarded following ideas, because
|
Beta2 is fine, just one thing that is missing is also that we extend Thus said I am not one hundred percent convinced our additions should stay in the Folder implementation, however there is some of the logic we need. We could have a SytemTag specific collection that could wrap it and so have little changes there, but would have a hard dependency on the Folder implementation (if only on few specific parts). Or we expose what is consolidated here as Would love to have @icewind1991's opinion on it. |
How about
|
|
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.
Overall approach seems fine.
Not a big fan of adding it as a public method to folder but not sure if there is a better option
lib/private/Files/Node/Folder.php
Outdated
// Currently query has to have exactly one search condition. If no media type is provided, | ||
// we fall back to the presence of a systemtag. | ||
if (empty($mediaType)) { | ||
$query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'systemtag', '%'), null, $limit, $offset); |
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.
does adding this operator do anything? LIKE '%'
seems to be always true to me
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.
It's a shortcut to get a query to pass to $searchHelper->findUsedTagsInCaches()
. Certainly this can be solved more elegantly. It was born out of the need to have something ready to bring Magenta back to a working state/environment.
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.
I suspect that this might interfere with picking an index so it would be better to have another way to flag that the query should join on tags.
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.
The behaviour appears same, however (checking with Postgrest) at some we'll have an Index Scan using oc_systemtag_pkey on oc_systemtag systemtag (cost=0.14..13.54 rows=69 width=20)
where the poential cost is slighlty lower when the comparison is not included. 13.54 instead of 13.72. May not be representative.
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.
Resolved with latest commit
@icewind1991 yes feeling the same. One way to reduce the footprint would be to expose |
But of course that leaves the changes within Or we indeed keep it provide as it is for now, just to have it merged. And have time to rethink internal structure and the PHP API, and be it for 28. I am a bit concerned though that the follow up would compete with other important tasks. |
e37f853
to
ab3bba2
Compare
Target case is photos app: when visiting the tags category, all systemtags of the whole cloud are retrieved. In subequent steps the next tag is requested until the browser view is filled with tag tiles (i.e. previews are requested just as well). With this approach, we incorpoate the dav search and look for user related tags that are used by them, and already returns the statistics (number of files tagged with the respective tag) as well as a file id for the purpose to load the preview. This defaults to the file with the highest id. Call: curl -s -u 'user:password' \ 'https://my.nc.srv/remote.php/dav/systemtags-current' \ -X PROPFIND -H 'Accept: text/plain' \ -H 'Accept-Language: en-US,en;q=0.5' -H 'Depth: 1' \ -H 'Content-Type: text/plain;charset=UTF-8' \ --data @/home/doe/request-systemtag-props.xml With request-systemtag-props.xml: <?xml version="1.0" encoding="UTF-8"?> <d:propfind xmlns:d="DAV:"> <d:prop xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"> <oc:id/> <oc:display-name/> <oc:user-visible/> <oc:user-assignable/> <oc:can-assign/> <nc:files-assigned/> <nc:reference-fileid/> </d:prop> </d:propfind> Example output: … <d:response> <d:href>/master/remote.php/dav/systemtags/84</d:href> <d:propstat> <d:prop> <oc:id>84</oc:id> <oc:display-name>Computer</oc:display-name> <oc:user-visible>true</oc:user-visible> <oc:user-assignable>true</oc:user-assignable> <oc:can-assign>true</oc:can-assign> <nc:files-assigned>42</nc:files-assigned> <nc:reference-fileid>924022</nc:reference-fileid> </d:prop> <d:status>HTTP/1.1 200 OK</d:status> </d:propstat> </d:response> <d:response> <d:href>/remote.php/dav/systemtags/97</d:href> <d:propstat> <d:prop> <oc:id>97</oc:id> <oc:display-name>Bear</oc:display-name> <oc:user-visible>true</oc:user-visible> <oc:user-assignable>true</oc:user-assignable> <oc:can-assign>true</oc:can-assign> <nc:files-assigned>1</nc:files-assigned> <nc:reference-fileid>923422</nc:reference-fileid> </d:prop> <d:status>HTTP/1.1 200 OK</d:status> </d:propstat> </d:response> … Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
- only the media part of the mime type can be search, but not the full mime type. It can be added, should it become necessary. - thus fixes previously hardcoded selector for image/ types - also fixes a return type hint - adds a return type hint Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
- DI SystemTagManager - add some comments and doc - catch NoUserException - add return type hints Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
- adds OC\SystemTag\SystemTagsInFilesDetector where the search logic is moved to Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
ab3bba2
to
dbfd2f9
Compare
@icewind1991 moved it to the search helper as suggested |
- search constraints are now fully in control of SystemTagsInFilesDetector::detectAssignedSystemTagsIn(), avoids duplication of a WHERE statement Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1891d1e
to
df662f5
Compare
failing drone CI tests unrelated |
Will need manual backports to 26 and 25 … although 26 might work, trying. |
/backport to stable26 |
/backport to stable25 |
The backport to stable26 failed. Please do this backport manually. # Switch to the target branch and update it
git checkout stable26
git pull origin/stable26
# Create the new backport branch
git checkout -b fix/foo-stable26
# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123
# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable26 More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport |
The backport to stable25 failed. Please do this backport manually. # Switch to the target branch and update it
git checkout stable25
git pull origin/stable25
# Create the new backport branch
git checkout -b fix/foo-stable25
# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123
# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable25 More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport |
backports created manually |
Summary
Target case is photos app: when visiting the tags category, all systemtags of the whole cloud are retrieved. In subsequent steps the next tag is requested until the browser view is filled with tag tiles (i.e. previews are requested just as well).
With this approach, we incorporate the dav search and look for user related tags that are used by them, and already returns the statistics (number of files tagged with the respective tag) as well as a file id for the purpose to load the preview. This defaults to the file with the highest id.
Call:
With request-systemtag-props.xml:
Example output:
Update 23/05/04
Added was support to retrieve tags for a specific media type. This works with the URI. So, while the
systemtags-current
root provides tag information across all files, querying/remote.php/dav/systemtags-current/image
will return tag information only for all image-typed files.In the first commit, the image-type condition was hard coded.
/Update
Update 23/05/04
The endpoint was renamed from
systemtags-current
tosystemtags-assigned
. The information at the top (before the updates) are adjusted./Update
TODO
Checklist