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>
This commit is contained in:
Cristian Scheid 2026-03-19 14:37:11 -03:00
parent 8225ab726f
commit 5bcac61c73
4 changed files with 11 additions and 5 deletions

View file

@ -41,7 +41,7 @@ export async function getContents(path = '/', options: { signal: AbortSignal }):
const contentsResponse = await client.search('/', {
signal: options.signal,
details: true,
data: getRecentSearch(lastTwoWeeksTimestamp, store.userConfig.recent_files_limit + 1),
data: getRecentSearch(lastTwoWeeksTimestamp, Number(store.userConfig.recent_files_limit)),
}) as ResponseDataDetailed<SearchResult>
const contents = contentsResponse.data.results

4
dist/files-init.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -153,7 +153,13 @@ class QuerySearchHelper {
$requestedFields = $this->searchBuilder->extractRequestedFields($searchQuery->getSearchOperation());
$query = $builder->selectFileCache('file', true);
$orderFields = array_map(fn ($order) => $order->getField(), $searchQuery->getOrder());
$joinExtendedCache = in_array('creation_time', $requestedFields)
|| in_array('upload_time', $requestedFields)
|| in_array('last_activity', $orderFields);
$query = $builder->selectFileCache('file', $joinExtendedCache);
if (in_array('systemtag', $requestedFields)) {
$this->equipQueryForSystemTags($query, $this->requireUser($searchQuery));