Skip to content
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

use more efficient tag retrieval on DAV report request #37969

Merged
merged 14 commits into from
Jun 28, 2023

Conversation

blizzz
Copy link
Member

@blizzz blizzz commented Apr 28, 2023

Summary

  • uses DAV search approach against valid files joined by systemtag selector
  • reduced table join for tag/systemtag search
  • supports pagination
  • no changes to the output formats or similar

Example request body:

<?xml version="1.0"?>
<oc:filter-files xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns" xmlns:ocs="http://open-collaboration-services.org/ns">
  <d:prop>
    <d:getcontentlength/>
    <d:getcontenttype/>
    <d:getetag/>
    <d:getlastmodified/>
    <d:resourcetype/>
    <nc:face-detections/>
    <nc:file-metadata-size/>
    <nc:has-preview/>
    <nc:realpath/>
    <oc:favorite/>
    <oc:fileid/>
    <oc:permissions/>
    <nc:nbItems/>
  </d:prop>
  <oc:filter-rules>
    <oc:systemtag>32</oc:systemtag>
  </oc:filter-rules>
  <d:limit>
    <d:nresults>50</d:nresults>
    <nc:firstresult>0</nc:firstresult>
  </d:limit>
</oc:filter-files>

Example call:

curl -s -u 'user:password' 'https://my.nxt.cld/remote.php/dav/files/user/' -X REPORT  -H 'Accept: text/plain'  -H 'Content-Type: text/plain;charset=UTF-8' --data @/home/nextcloud/report-people-tag.xml

ℹ️ the base branch is #37961 This PR is an addition to it, but I keep it seperated for smaller changesets.

TODO

  • Performance testing with a serious data set
  • Reconsider pragmatic architectual choices (quick PoC)

Checklist

@blizzz blizzz force-pushed the poc/noid/systemtags-perf-tag-endpoint branch from d40537b to 512a4b4 Compare May 2, 2023 07:39
@skjnldsv skjnldsv mentioned this pull request May 3, 2023
@blizzz blizzz force-pushed the poc/noid/systemtags-perf-tag-endpoint branch from ce5ea9c to 91a3750 Compare May 4, 2023 10:00
This was referenced May 9, 2023
@blizzz blizzz force-pushed the poc/noid/systemtags-perf branch 2 times, most recently from ab3bba2 to dbfd2f9 Compare May 9, 2023 21:59
Base automatically changed from poc/noid/systemtags-perf to master May 11, 2023 08:16
@blizzz blizzz force-pushed the poc/noid/systemtags-perf-tag-endpoint branch from 91a3750 to 9bbbab0 Compare May 11, 2023 10:36
@blizzz
Copy link
Member Author

blizzz commented May 11, 2023

  • breaks universal search by tags

@blizzz blizzz changed the title PoC use more efficient tag retrieval on DAV report request use more efficient tag retrieval on DAV report request May 11, 2023
@blizzz blizzz requested a review from marcelklehr May 11, 2023 11:24
blizzz added 5 commits June 21, 2023 20:28
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
- possible null return
- parameter name mismatch in implementation
- incomplete unit test

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz blizzz force-pushed the poc/noid/systemtags-perf-tag-endpoint branch from bca6d7f to a0b6834 Compare June 21, 2023 18:28
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz blizzz requested a review from marcelklehr June 21, 2023 19:10
@nickvergessen nickvergessen removed their request for review June 22, 2023 07:16
$this->equipQueryForSystemTags($query, $this->requireUser($searchQuery));
}
if (in_array('tagname', $requestedFields) || in_array('favorite', $requestedFields)) {
$this->equipQueryForDavTags($query, $this->requireUser($searchQuery));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@juliusknorr
Copy link
Member

To adapt

  • group folders: PHP Fatal error: Class OCA\GroupFolders\Helper\LazyFolder contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (OCP\Files\Folder::searchBySystemTag) in /var/www/html/apps-extra/groupfolders/lib/Helper/LazyFolder.php on line 32

Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good and seem do the trick

Blocking for missing docs as the public API is changed:

@blizzz Can you prepare a companion PR for the documentation update on the API changes and maybe also with the short doc section about the system tag retrieval that you mentioned? Then we can merge them in sync ;)


foreach ($tags as $tag) {
$tagName = $tag->getName();
$tmpNodes = $this->userFolder->searchBySystemTag($tagName, $this->userSession->getUser()->getUID(), $dbLimit, $dbOffset);

Check notice

Code scanning / Psalm

PossiblyNullReference

Cannot call method getUID on possibly null value
// Empty intersection, nothing can show up anymore
return [];
if (!$oneTagSearch && ($limit !== null || $offset !== null)) {
$nodes = array_slice($nodes, $offset, $limit);

Check notice

Code scanning / Psalm

PossiblyNullArgument

Argument 2 of array_slice cannot be null, possibly null value provided
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz
Copy link
Member Author

blizzz commented Jun 27, 2023

Changes look good and seem do the trick

Blocking for missing docs as the public API is changed:

@blizzz Can you prepare a companion PR for the documentation update on the API changes and maybe also with the short doc section about the system tag retrieval that you mentioned? Then we can merge them in sync ;)

The API Changes at: nextcloud/documentation#10678

The other thing you refer to, that would be the DAV endpoint extension from the first PR?

@juliusknorr juliusknorr merged commit eddb64f into master Jun 28, 2023
@juliusknorr juliusknorr deleted the poc/noid/systemtags-perf-tag-endpoint branch June 28, 2023 05:53
@juliusknorr
Copy link
Member

Thanks, a right that was the other one. Yes, that would be nice to have as well :)

@backportbot-nextcloud
Copy link

The backport to adapt failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout adapt
git pull origin adapt

# Create the new backport branch
git checkout -b fix/foo-adapt

# 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-adapt

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@blizzz
Copy link
Member Author

blizzz commented Jul 6, 2023

/backport to stable27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants