Skip to content

Commit e964351

Browse files
feat: add upload_time support to file search and recent files
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
1 parent c56938f commit e964351

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

apps/dav/lib/Files/FileSearchBackend.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function getPropertyDefinitionsForScope(string $href, ?string $path): arr
8686
new SearchPropertyDefinition('{DAV:}displayname', true, true, true),
8787
new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true),
8888
new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
89+
new SearchPropertyDefinition('{http://nextcloud.org/ns}upload_time', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
8990
new SearchPropertyDefinition(FilesPlugin::SIZE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
9091
new SearchPropertyDefinition(TagsPlugin::FAVORITE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_BOOLEAN),
9192
new SearchPropertyDefinition(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, true, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
@@ -298,6 +299,8 @@ private function getSearchResultProperty(SearchResult $result, SearchPropertyDef
298299
return $node->getName();
299300
case '{DAV:}getlastmodified':
300301
return $node->getLastModified();
302+
case '{http://nextcloud.org/ns}upload_time':
303+
return $node->getNode()->getUploadTime();
301304
case FilesPlugin::SIZE_PROPERTYNAME:
302305
return $node->getSize();
303306
case FilesPlugin::INTERNAL_FILEID_PROPERTYNAME:
@@ -458,6 +461,8 @@ private function mapPropertyNameToColumn(SearchPropertyDefinition $property) {
458461
return 'mimetype';
459462
case '{DAV:}getlastmodified':
460463
return 'mtime';
464+
case '{http://nextcloud.org/ns}upload_time':
465+
return 'upload_time';
461466
case FilesPlugin::SIZE_PROPERTYNAME:
462467
return 'size';
463468
case TagsPlugin::FAVORITE_PROPERTYNAME:

lib/private/Files/Cache/QuerySearchHelper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,12 @@ public function searchInCaches(ISearchQuery $searchQuery, array $caches): array
151151

152152
$builder = $this->getQueryBuilder();
153153

154-
$query = $builder->selectFileCache('file', false);
155-
156154
$requestedFields = $this->searchBuilder->extractRequestedFields($searchQuery->getSearchOperation());
157155

156+
$joinExtendedCache = in_array('upload_time', $requestedFields);
157+
158+
$query = $builder->selectFileCache('file', $joinExtendedCache);
159+
158160
if (in_array('systemtag', $requestedFields)) {
159161
$this->equipQueryForSystemTags($query, $this->requireUser($searchQuery));
160162
}

lib/private/Files/Cache/SearchBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class SearchBuilder {
6464
'share_with' => 'string',
6565
'share_type' => 'integer',
6666
'owner' => 'string',
67+
'upload_time' => 'integer',
6768
];
6869

6970
/** @var array<string, int|string> */
@@ -257,6 +258,7 @@ private function validateComparison(ISearchComparison $operator) {
257258
'share_with' => ['eq'],
258259
'share_type' => ['eq'],
259260
'owner' => ['eq'],
261+
'upload_time' => ['eq', 'gt', 'lt', 'gte', 'lte'],
260262
];
261263

262264
if (!isset(self::$fieldTypes[$operator->getField()])) {

0 commit comments

Comments
 (0)