Skip to content

Commit 40362f5

Browse files
refactor(recent-search): use order by fields to determine extended cache join and cast config limit to number
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
1 parent a699eed commit 40362f5

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

apps/files/src/services/Recent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function getContents(path = '/', options: { signal: AbortSignal }):
4141
const contentsResponse = await client.search('/', {
4242
signal: options.signal,
4343
details: true,
44-
data: getRecentSearch(lastTwoWeeksTimestamp, store.userConfig.recent_files_limit + 1),
44+
data: getRecentSearchCustom(lastTwoWeeksTimestamp, Number(store.userConfig.recent_files_limit)),
4545
}) as ResponseDataDetailed<SearchResult>
4646

4747
const contents = contentsResponse.data.results

dist/files-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/private/Files/Cache/QuerySearchHelper.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,13 @@ public function searchInCaches(ISearchQuery $searchQuery, array $caches): array
153153

154154
$requestedFields = $this->searchBuilder->extractRequestedFields($searchQuery->getSearchOperation());
155155

156-
$query = $builder->selectFileCache('file', true);
156+
$orderFields = array_map(fn($order) => $order->getField(), $searchQuery->getOrder());
157+
158+
$joinExtendedCache = in_array('creation_time', $requestedFields)
159+
|| in_array('upload_time', $requestedFields)
160+
|| in_array('last_activity', $orderFields);
161+
162+
$query = $builder->selectFileCache('file', $joinExtendedCache);
157163

158164
if (in_array('systemtag', $requestedFields)) {
159165
$this->equipQueryForSystemTags($query, $this->requireUser($searchQuery));

0 commit comments

Comments
 (0)