Search: Add sort by "File Size" #2620

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2022-10-24 12:56:17 +02:00
parent d58189ea8f
commit ac84dce3aa
3 changed files with 12 additions and 8 deletions

View file

@ -202,14 +202,15 @@ export default {
{value: 'list', text: this.$gettext('List')},
],
'sorting': [
{value: 'added', text: this.$gettext('Recently added')},
{value: 'edited', text: this.$gettext('Recently edited')},
{value: 'newest', text: this.$gettext('Newest first')},
{value: 'oldest', text: this.$gettext('Oldest first')},
{value: 'name', text: this.$gettext('Sort by file name')},
{value: 'similar', text: this.$gettext('Group by similarity')},
{value: 'relevance', text: this.$gettext('Most relevant')},
{value: 'duration', text: this.$gettext('Duration')},
{value: 'added', text: this.$gettext('Recently Added')},
{value: 'newest', text: this.$gettext('Newest First')},
{value: 'oldest', text: this.$gettext('Oldest First')},
{value: 'relevance', text: this.$gettext('Most Relevant')},
{value: 'similar', text: this.$gettext('Visual Similarity')},
{value: 'name', text: this.$gettext('File Name')},
{value: 'size', text: this.$gettext('File Size')},
{value: 'duration', text: this.$gettext('Video Duration')},
{value: 'edited', text: this.$gettext('Recently Edited')},
],
},
};

View file

@ -57,6 +57,7 @@ const (
SortOrderDefault = ""
SortOrderRelevance = "relevance"
SortOrderDuration = "duration"
SortOrderSize = "size"
SortOrderCount = "count"
SortOrderAdded = "added"
SortOrderImported = "imported"

View file

@ -147,6 +147,8 @@ func searchPhotos(f form.SearchPhotos, sess *entity.Session, resultCols string)
}
case entity.SortOrderDuration:
s = s.Order("photos.photo_duration DESC, files.time_index")
case entity.SortOrderSize:
s = s.Order("files.file_size DESC, files.time_index")
case entity.SortOrderNewest:
s = s.Order("files.time_index")
case entity.SortOrderOldest: