Skip to content

Commit 3d495a0

Browse files
committed
Fix age sort direction and revert broad getSort null change
- Revert IS NULL addition in getSort (caused unintended side effects) - Add targeted birthdate case in getPerformerSort that flips direction (birthdate is inverse to age: lower date = older, so ASC exchanges with DESC) and adds IS NULL for nulls-last behavior
1 parent 2c3674f commit 3d495a0

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

pkg/sqlite/performer.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,17 @@ func (qb *PerformerStore) getPerformerSort(findFilter *models.FindFilterType) (s
872872
sortQuery += qb.sortByLastOAt(direction)
873873
case "latest_scene":
874874
sortQuery += qb.sortByLatestScene(direction)
875+
case "birthdate":
876+
// birthdate is inversely related to age (older = lower date).
877+
// flip direction so DESC means "oldest first".
878+
colName := getColumn(performerTable, "birthdate")
879+
dir := getSortDirection(direction)
880+
if dir == "ASC" {
881+
dir = "DESC"
882+
} else {
883+
dir = "ASC"
884+
}
885+
sortQuery += " ORDER BY " + colName + " IS NULL, " + colName + " " + dir
875886
default:
876887
sortQuery += getSort(sort, direction, "performers")
877888
}

pkg/sqlite/sql.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func getSort(sort string, direction string, tableName string) string {
9999
return " ORDER BY COUNT(distinct " + colName + ") " + direction
100100
case strings.Compare(sort, "filesize") == 0:
101101
colName := getColumn(tableName, "size")
102-
return " ORDER BY " + colName + " IS NULL, " + colName + " " + direction
102+
return " ORDER BY " + colName + " " + direction
103103
case strings.HasPrefix(sort, randomSeedPrefix):
104104
// seed as a parameter from the UI
105105
seedStr := sort[len(randomSeedPrefix):]
@@ -117,13 +117,13 @@ func getSort(sort string, direction string, tableName string) string {
117117
colName = sort
118118
}
119119
if strings.Compare(sort, "name") == 0 {
120-
return " ORDER BY " + colName + " IS NULL, " + colName + " COLLATE NATURAL_CI " + direction
120+
return " ORDER BY " + colName + " COLLATE NATURAL_CI " + direction
121121
}
122122
if strings.Compare(sort, "title") == 0 {
123-
return " ORDER BY " + colName + " IS NULL, " + colName + " COLLATE NATURAL_CI " + direction
123+
return " ORDER BY " + colName + " COLLATE NATURAL_CI " + direction
124124
}
125125

126-
return " ORDER BY " + colName + " IS NULL, " + colName + " " + direction
126+
return " ORDER BY " + colName + " " + direction
127127
}
128128
}
129129

0 commit comments

Comments
 (0)