Albums: Set default sort order to "oldest first"
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
65a7ee01f2
commit
9f188a7b93
3 changed files with 16 additions and 7 deletions
|
@ -51,6 +51,7 @@ func NewAlbum(albumName string) *Album {
|
|||
result := &Album{
|
||||
AlbumSlug: albumSlug,
|
||||
AlbumName: albumName,
|
||||
AlbumOrder: SortOrderOldest,
|
||||
}
|
||||
|
||||
return result
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package entity
|
||||
|
||||
const (
|
||||
// data sources
|
||||
SrcAuto = ""
|
||||
SrcManual = "manual"
|
||||
SrcLocation = "location"
|
||||
|
@ -9,4 +10,11 @@ const (
|
|||
SrcXmp = "xmp"
|
||||
SrcYml = "yml"
|
||||
SrcJson = "json"
|
||||
|
||||
// sort orders
|
||||
SortOrderRelevance = "relevance"
|
||||
SortOrderNewest = "newest"
|
||||
SortOrderOldest = "oldest"
|
||||
SortOrderImported = "imported"
|
||||
SortOrderSimilar = "similar"
|
||||
)
|
|
@ -317,15 +317,15 @@ func (q *Query) Photos(f form.PhotoSearch) (results []PhotoResult, err error) {
|
|||
}
|
||||
|
||||
switch f.Order {
|
||||
case "relevance":
|
||||
case entity.SortOrderRelevance:
|
||||
s = s.Order("photo_story DESC, photo_favorite DESC, taken_at DESC")
|
||||
case "newest":
|
||||
case entity.SortOrderNewest:
|
||||
s = s.Order("taken_at DESC, photos.photo_uuid")
|
||||
case "oldest":
|
||||
case entity.SortOrderOldest:
|
||||
s = s.Order("taken_at, photos.photo_uuid")
|
||||
case "imported":
|
||||
case entity.SortOrderImported:
|
||||
s = s.Order("photos.id DESC")
|
||||
case "similar":
|
||||
case entity.SortOrderSimilar:
|
||||
s = s.Order("files.file_main_color, photos.location_id, files.file_diff, taken_at DESC")
|
||||
default:
|
||||
s = s.Order("taken_at DESC, photos.photo_uuid")
|
||||
|
|
Loading…
Reference in a new issue