Skip to content

Sort office search newest-first and cap at 500 results#16

Open
juliusknorr wants to merge 2 commits into
mainfrom
fix/search-sort-limit
Open

Sort office search newest-first and cap at 500 results#16
juliusknorr wants to merge 2 commits into
mainfrom
fix/search-sort-limit

Conversation

@juliusknorr
Copy link
Copy Markdown
Member

Adds <d:orderby> (getlastmodified descending) and <d:limit> (500) to the WebDAV SEARCH so the server returns only the 500 most recently modified office files. UI display cap raised to match.

🤖 Generated with Claude Code

Add <d:orderby> (getlastmodified descending) and <d:limit> to the WebDAV
SEARCH so the server returns only the 500 most recently modified results.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Julius Knorr <jus@bitgrid.net>
@juliusknorr juliusknorr force-pushed the fix/search-sort-limit branch from eebf71f to a099d35 Compare May 29, 2026 07:37
@juliusknorr
Copy link
Copy Markdown
Member Author

/backport to stable34

@backportbot backportbot Bot added the backport-request A backport was requested for this pull request label May 29, 2026
@moodyjmz
Copy link
Copy Markdown
Contributor

@juliusknorr I'm not so familiar with the server, but does this not mean the frontend will not be aware of other files and therefore can't show a button to load more?

const hasMoreFiles = computed(() => filteredFiles.value.length > MAX_DISPLAY_FILES)

@moodyjmz
Copy link
Copy Markdown
Contributor

@juliusknorr Is there some meta endpoint we can ping to get file count?

@moodyjmz
Copy link
Copy Markdown
Contributor

I asked Claude: No — Nextcloud's DAVSEARCH doesn't support RFC 5323 aggregate COUNT, and there's no OCS endpoint for a mime-type file count either. The only way to know the true total is to fetch all
matching files, which is exactly what this PR avoids doing.

The practical fix for hasMoreFiles is simpler: if the server returned exactly 500 results, assume there may be more and show a "showing newest 500" notice rather than trying to compute
an exact count.

@moodyjmz
Copy link
Copy Markdown
Contributor

A fix

Current (src/views/OfficeOverview.vue:119–120):

  const files = computed(() => filteredFiles.value.slice(0, MAX_DISPLAY_FILES))
  const hasMoreFiles = computed(() => filteredFiles.value.length > MAX_DISPLAY_FILES)

Fix:

  const files = computed(() => filteredFiles.value)
  const hasMoreFiles = computed(() => allFiles.value.length >= MAX_DISPLAY_FILES)

@juliusknorr
Copy link
Copy Markdown
Member Author

Ok, let me adjust, then we need to also pass the offset to the search request.

Replace the body <d:limit> with Nextcloud's pagination headers
(X-NC-Paginate / X-NC-Paginate-Count) and read X-NC-Paginate-Total so
the UI knows whether more files exist than were returned. Drives
hasMoreFiles from the real total instead of the display cap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-request A backport was requested for this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants