1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Making preview manager to first find photo in the same directory then in any subdirectories without any ordering between subdirectories.

This commit is contained in:
Patrik J. Braun 2022-02-06 11:36:45 +01:00
parent 0d519055d5
commit 42fd161a66

View File

@ -160,11 +160,9 @@ export class PreviewManager implements IPreviewManager {
});
}
}));
if (Config.Server.Database.type === DatabaseType.mysql) {
query.orderBy('CHAR_LENGTH(directory.path)', 'ASC'); // shorter the path, its higher up in the hierarchy
} else {
query.orderBy('LENGTH(directory.path)', 'ASC'); // shorter the path, its higher up in the hierarchy
}
// Select from the directory if any otherwise from any subdirectories.
// (There is no priority between subdirectories)
query.orderBy(`CASE WHEN directory.id = ${dir.id} THEN 0 ELSE 1 END`, 'ASC');
PreviewManager.setSorting(query);