From 9ceb90c4a296877bea338a111fb0e44968e582a3 Mon Sep 17 00:00:00 2001 From: grasdk Date: Sun, 16 Jun 2024 20:44:35 +0200 Subject: [PATCH 1/2] added coalesce to search queries in case offset is null --- src/backend/model/database/SearchManager.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/backend/model/database/SearchManager.ts b/src/backend/model/database/SearchManager.ts index 0099bf11..1c54a232 100644 --- a/src/backend/model/database/SearchManager.ts +++ b/src/backend/model/database/SearchManager.ts @@ -365,7 +365,7 @@ export class SearchManager { switch (sort.method) { case SortByTypes.Date: if (Config.Gallery.ignoreTimestampOffset === true) { - query.addOrderBy('media.metadata.creationDate + (media.metadata.creationDateOffset * 60000)', sort.ascending ? 'ASC' : 'DESC'); + query.addOrderBy('media.metadata.creationDate + (coalesce(media.metadata.creationDateOffset,0) * 60000)', sort.ascending ? 'ASC' : 'DESC'); } else { query.addOrderBy('media.metadata.creationDate', sort.ascending ? 'ASC' : 'DESC'); } @@ -568,7 +568,7 @@ export class SearchManager { textParam['from' + queryId] = (query as FromDateSearch).value; if (Config.Gallery.ignoreTimestampOffset === true) { q.where( - `(media.metadata.creationDate + (media.metadata.creationDateOffset * 60000)) ${relation} :from${queryId}`, + `(media.metadata.creationDate + (coalesce(media.metadata.creationDateOffset,0) * 60000)) ${relation} :from${queryId}`, textParam ); } else { @@ -597,7 +597,7 @@ export class SearchManager { textParam['to' + queryId] = (query as ToDateSearch).value; if (Config.Gallery.ignoreTimestampOffset === true) { q.where( - `(media.metadata.creationDate + (media.metadata.creationDateOffset * 60000)) ${relation} :to${queryId}`, + `(media.metadata.creationDate + (coalesce(media.metadata.creationDateOffset,0) * 60000)) ${relation} :to${queryId}`, textParam ); } else { @@ -809,9 +809,9 @@ export class SearchManager { if (tq.negate) { if (Config.Gallery.ignoreTimestampOffset === true) { q.where( - `(media.metadata.creationDate + (media.metadata.creationDateOffset * 60000)) >= :to${queryId}`, + `(media.metadata.creationDate + (coalesce(media.metadata.creationDateOffset,0) * 60000)) >= :to${queryId}`, textParam - ).orWhere(`(media.metadata.creationDate + (media.metadata.creationDateOffset * 60000)) < :from${queryId}`, + ).orWhere(`(media.metadata.creationDate + (coalesce(media.metadata.creationDateOffset,0) * 60000)) < :from${queryId}`, textParam); } else { q.where( @@ -824,9 +824,9 @@ export class SearchManager { } else { if (Config.Gallery.ignoreTimestampOffset === true) { q.where( - `(media.metadata.creationDate + (media.metadata.creationDateOffset * 60000)) < :to${queryId}`, + `(media.metadata.creationDate + (coalesce(media.metadata.creationDateOffset,0) * 60000)) < :to${queryId}`, textParam - ).andWhere(`(media.metadata.creationDate + (media.metadata.creationDateOffset * 60000)) >= :from${queryId}`, + ).andWhere(`(media.metadata.creationDate + (coalesce(media.metadata.creationDateOffset,0) * 60000)) >= :from${queryId}`, textParam); } else { q.where( From 671065c6ac427342e36c47192b3f245e9eaa0da8 Mon Sep 17 00:00:00 2001 From: grasdk Date: Sun, 16 Jun 2024 22:46:20 +0200 Subject: [PATCH 2/2] Making the config option title a bit more clear --- src/common/config/public/ClientConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/config/public/ClientConfig.ts b/src/common/config/public/ClientConfig.ts index c6adfe09..1621e700 100644 --- a/src/common/config/public/ClientConfig.ts +++ b/src/common/config/public/ClientConfig.ts @@ -1084,7 +1084,7 @@ export class ClientGalleryConfig { @ConfigProperty({ tags: { - name: $localize`Ignore timestamp offsets`, + name: $localize`Ignore timestamp offsets (use local time)`, priority: ConfigPriority.advanced, }, description: $localize`If enabled, timestamp offsets are ignored, meaning that the local times of pictures are used for searching, sorting and grouping. If disabled, global time is used and pictures with no timestamp are assumed to be in UTC (offset +00:00).`