Fix non-deterministic color sort order

This commit is contained in:
Sam Becker 2025-08-04 09:48:18 -05:00
parent 4890b17868
commit bde87c2542

View File

@ -178,14 +178,15 @@ export const getOrderByFromOptions = (options: PhotoQueryOptions) => {
return sortWithPriority return sortWithPriority
? 'ORDER BY priority_order ASC, created_at ASC' ? 'ORDER BY priority_order ASC, created_at ASC'
: 'ORDER BY created_at ASC'; : 'ORDER BY created_at ASC';
// Add date sort to account for photos with same color sort
case 'color': case 'color':
return sortWithPriority return sortWithPriority
? 'ORDER BY priority_order ASC, color_sort DESC' ? 'ORDER BY priority_order ASC, color_sort DESC, taken_at DESC'
: 'ORDER BY color_sort DESC'; : 'ORDER BY color_sort DESC, taken_at DESC';
case 'colorAsc': case 'colorAsc':
return sortWithPriority return sortWithPriority
? 'ORDER BY priority_order ASC, color_sort ASC' ? 'ORDER BY priority_order ASC, color_sort ASC, taken_at DESC'
: 'ORDER BY color_sort ASC'; : 'ORDER BY color_sort ASC, taken_at DESC';
} }
}; };