diff --git a/src/backend/model/database/SearchManager.ts b/src/backend/model/database/SearchManager.ts index 9977ca65..2e3bb8c5 100644 --- a/src/backend/model/database/SearchManager.ts +++ b/src/backend/model/database/SearchManager.ts @@ -364,7 +364,7 @@ export class SearchManager { for (const sort of sortings) { switch (sort.method) { case SortByTypes.Date: - query.addOrderBy('media.metadata.creationDate', sort.ascending ? 'ASC' : 'DESC'); //If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). If taken into account, it will alter the sort order. Probably should not be done. + query.addOrderBy('media.metadata.creationDate', sort.ascending ? 'ASC' : 'DESC'); //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). If taken into account, it will alter the sort order. Probably should not be done. break; case SortByTypes.Rating: query.addOrderBy('media.metadata.rating', sort.ascending ? 'ASC' : 'DESC'); @@ -563,7 +563,7 @@ export class SearchManager { const textParam: { [key: string]: unknown } = {}; textParam['from' + queryId] = (query as FromDateSearch).value; q.where( - `media.metadata.creationDate ${relation} :from${queryId}`, //TODO: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). + `media.metadata.creationDate ${relation} :from${queryId}`, //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). //Example: -600 means in the database UTC-10:00. The time 20:00 in the evening in the UTC-10 timezone, is actually 06:00 the next morning //in UTC+00:00. To make search take that into account, one can subtract the offset from the creationDate to "pretend" the photo is taken //in UTC time. Subtracting -600 minutes (because it's the -10:00 timezone), corresponds to adding 10 hours to the photo's timestamp, thus @@ -590,7 +590,7 @@ export class SearchManager { const textParam: { [key: string]: unknown } = {}; textParam['to' + queryId] = (query as ToDateSearch).value; q.where( - `media.metadata.creationDate ${relation} :to${queryId}`, //TODO: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. + `media.metadata.creationDate ${relation} :to${queryId}`, //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. textParam ); @@ -795,15 +795,15 @@ export class SearchManager { if (tq.negate) { q.where( - `media.metadata.creationDate >= :to${queryId}`, //TODO: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. + `media.metadata.creationDate >= :to${queryId}`, //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. textParam - ).orWhere(`media.metadata.creationDate < :from${queryId}`, //TODO: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. + ).orWhere(`media.metadata.creationDate < :from${queryId}`, //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. textParam); } else { q.where( - `media.metadata.creationDate < :to${queryId}`, //TODO: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. + `media.metadata.creationDate < :to${queryId}`, //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. textParam - ).andWhere(`media.metadata.creationDate >= :from${queryId}`, //TODO: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. + ).andWhere(`media.metadata.creationDate >= :from${queryId}`, //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. textParam); } @@ -826,12 +826,12 @@ export class SearchManager { if (Config.Database.type === DatabaseType.sqlite) { if (tq.daysLength == 0) { q.where( - //TODO: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. + //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. `CAST(strftime('${duration}',media.metadataCreationDate/1000, 'unixepoch') AS INTEGER) ${relationEql} CAST(strftime('${duration}','now') AS INTEGER)` ); } else { q.where( - //TODO: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. + //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. `CAST(strftime('${duration}',media.metadataCreationDate/1000, 'unixepoch') AS INTEGER) ${relationTop} CAST(strftime('${duration}','now') AS INTEGER)` )[whereFN](`CAST(strftime('${duration}',media.metadataCreationDate/1000, 'unixepoch') AS INTEGER) ${relationBottom} CAST(strftime('${duration}','now','-:diff${queryId} day') AS INTEGER)`, textParam); @@ -839,12 +839,12 @@ export class SearchManager { } else { if (tq.daysLength == 0) { q.where( - //TODO: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. + //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. `CAST(FROM_UNIXTIME(media.metadataCreationDate/1000, '${duration}') AS SIGNED) ${relationEql} CAST(DATE_FORMAT(CURDATE(),'${duration}') AS SIGNED)` ); } else { q.where( - //TODO: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. + //TODO: Offset: If media.metadata.creationDateOffset is defined, it is an offset of minutes (+/-). See explanation above. `CAST(FROM_UNIXTIME(media.metadataCreationDate/1000, '${duration}') AS SIGNED) ${relationTop} CAST(DATE_FORMAT(CURDATE(),'${duration}') AS SIGNED)` )[whereFN](`CAST(FROM_UNIXTIME(media.metadataCreationDate/1000, '${duration}') AS SIGNED) ${relationBottom} CAST(DATE_FORMAT((DATE_ADD(curdate(), INTERVAL -:diff${queryId} DAY)),'${duration}') AS SIGNED)`, textParam); diff --git a/src/backend/model/fileaccess/DiskManager.ts b/src/backend/model/fileaccess/DiskManager.ts index e07ff2e3..2c769b67 100644 --- a/src/backend/model/fileaccess/DiskManager.ts +++ b/src/backend/model/fileaccess/DiskManager.ts @@ -277,7 +277,7 @@ export class DiskManager { directory.oldestMedia = Number.MIN_SAFE_INTEGER; directory.media.forEach((m) => { - directory.youngestMedia = Math.min(m.metadata.creationDate, directory.youngestMedia); + directory.youngestMedia = Math.min(m.metadata.creationDate, directory.youngestMedia); //TODO: Offset: directory.oldestMedia = Math.max(m.metadata.creationDate, directory.oldestMedia); } ); diff --git a/src/backend/model/messenger/EmailMessenger.ts b/src/backend/model/messenger/EmailMessenger.ts index c9afd8a9..6e2ed138 100644 --- a/src/backend/model/messenger/EmailMessenger.ts +++ b/src/backend/model/messenger/EmailMessenger.ts @@ -70,7 +70,7 @@ export class EmailMessenger extends Messenger<{ (media[i].metadata as PhotoMetadata).positionData?.country : ((media[i].metadata as PhotoMetadata).positionData?.city ? (media[i].metadata as PhotoMetadata).positionData?.city : ''); - const caption = Utils.getFullYear(media[i].metadata.creationDate, media[i].metadata.creationDateOffset) + (location ? ', ' + location : ''); + const caption = Utils.getFullYear(media[i].metadata.creationDate, media[i].metadata.creationDateOffset) + (location ? ', ' + location : ''); //TODO: Offset: attachments.push({ filename: media[i].name, path: media[i].thumbnailPath, diff --git a/src/backend/model/messenger/Messenger.ts b/src/backend/model/messenger/Messenger.ts index 2b867f74..d48f6506 100644 --- a/src/backend/model/messenger/Messenger.ts +++ b/src/backend/model/messenger/Messenger.ts @@ -33,7 +33,7 @@ export abstract class Messenger = Record 0 && (input as MediaDTO[])[0]?.name && (input as MediaDTO[])[0]?.directory - && (input as MediaDTO[])[0]?.metadata?.creationDate) { + && (input as MediaDTO[])[0]?.metadata?.creationDate) { //TODO: Offset: const media = input as MediaDTOWithThPath[]; for (let i = 0; i < media.length; ++i) { media[i].thumbnailPath = await this.getThumbnail(media[i]); diff --git a/src/frontend/app/ui/duplicates/duplicates.component.html b/src/frontend/app/ui/duplicates/duplicates.component.html index f1168a73..5c2d1678 100644 --- a/src/frontend/app/ui/duplicates/duplicates.component.html +++ b/src/frontend/app/ui/duplicates/duplicates.component.html @@ -23,7 +23,7 @@
{{media.metadata.fileSize | fileSize}}
-
+
{{ media.metadata.creationDate | date : 'longDate' : (media.metadata.creationDateOffset ? media.metadata.creationDateOffset : 'UTC') }}, {{ media.metadata.creationDate | date : (media.metadata.creationDateOffset ? 'HH:mm:ss ZZZZZ' : 'HH:mm:ss') : (media.metadata.creationDateOffset ? media.metadata.creationDateOffset : 'UTC') }}
diff --git a/src/frontend/app/ui/gallery/blog/blog.service.ts b/src/frontend/app/ui/gallery/blog/blog.service.ts index 917cf891..fb3500ae 100644 --- a/src/frontend/app/ui/gallery/blog/blog.service.ts +++ b/src/frontend/app/ui/gallery/blog/blog.service.ts @@ -28,7 +28,7 @@ export class BlogService { let firstMedia = Number.MAX_SAFE_INTEGER; if (content.mediaGroups.length > 0) { firstMedia = content.mediaGroups[0].media.reduce((p, m) => - Math.min(m.metadata.creationDate, p), Number.MAX_SAFE_INTEGER); + Math.min(m.metadata.creationDate, p), Number.MAX_SAFE_INTEGER); //TODO: Offset: } const files = this.mdFilesFilterPipe.transform(content.metaFile) diff --git a/src/frontend/app/ui/gallery/filter/filter.service.ts b/src/frontend/app/ui/gallery/filter/filter.service.ts index e6bbf234..ca84ff24 100644 --- a/src/frontend/app/ui/gallery/filter/filter.service.ts +++ b/src/frontend/app/ui/gallery/filter/filter.service.ts @@ -159,11 +159,11 @@ export class FilterService { } const ret: { date: Date, endDate: Date, dateStr: string, count: number, max: number }[] = []; const minDate = prefiltered.media.reduce( - (p, curr) => Math.min(p, curr.metadata.creationDate), + (p, curr) => Math.min(p, curr.metadata.creationDate), //TODO: Offset: Number.MAX_VALUE - 1 ); const maxDate = prefiltered.media.reduce( - (p, curr) => Math.max(p, curr.metadata.creationDate), + (p, curr) => Math.max(p, curr.metadata.creationDate), //TODO: Offset: Number.MIN_VALUE + 1 ); const diff = (maxDate - minDate) / 1000; @@ -205,7 +205,7 @@ export class FilterService { const startMediaDate = new Date(floorDate(minDate)); prefiltered.media.forEach(m => { - const key = Math.floor((floorDate(m.metadata.creationDate) - startMediaDate.getTime()) / 1000 / usedDiv); //TODO + const key = Math.floor((floorDate(m.metadata.creationDate) - startMediaDate.getTime()) / 1000 / usedDiv); //TODO: Offset: const getDate = (index: number) => { let d: Date; @@ -273,11 +273,11 @@ export class FilterService { if (c.media.length > 0) { // Update date filter range afilters.dateFilter.minDate = c.media.reduce( - (p, curr) => Math.min(p, curr.metadata.creationDate), + (p, curr) => Math.min(p, curr.metadata.creationDate), //TODO: Offset: Number.MAX_VALUE - 1 ); afilters.dateFilter.maxDate = c.media.reduce( - (p, curr) => Math.max(p, curr.metadata.creationDate), + (p, curr) => Math.max(p, curr.metadata.creationDate), //TODO: Offset: Number.MIN_VALUE + 1 ); // Add a few sec padding @@ -294,8 +294,8 @@ export class FilterService { // Apply Date filter c.media = c.media.filter( (m) => - m.metadata.creationDate >= afilters.dateFilter.minFilter && - m.metadata.creationDate <= afilters.dateFilter.maxFilter + m.metadata.creationDate >= afilters.dateFilter.minFilter && //TODO: Offset: + m.metadata.creationDate <= afilters.dateFilter.maxFilter //TODO: Offset: ); } else { afilters.dateFilter.minDate = Number.MIN_VALUE; @@ -398,5 +398,3 @@ export class FilterService { } } } - - diff --git a/src/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.ts b/src/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.ts index 71c211ad..bde3467e 100644 --- a/src/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.ts +++ b/src/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.ts @@ -508,7 +508,7 @@ export class ControlsLightboxComponent implements OnDestroy, OnInit, OnChanges { case LightBoxTitleTexts.persons: return m.metadata.faces?.map(f => f.name)?.join(', '); case LightBoxTitleTexts.date: - return this.datePipe.transform(m.metadata.creationDate, 'longDate', m.metadata.creationDateOffset); + return this.datePipe.transform(m.metadata.creationDate, 'longDate', m.metadata.creationDateOffset); //TODO: Offset: case LightBoxTitleTexts.location: if (!m.metadata.positionData) { return ''; diff --git a/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html b/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html index 341aa65a..4bc7e82a 100644 --- a/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html +++ b/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html @@ -54,7 +54,7 @@
- {{ media.metadata.creationDate | date: (isThisYear() ? 'MMMM d' : 'longDate') : (media.metadata.creationDateOffset ? media.metadata.creationDateOffset : 'UTC') }} + {{ media.metadata.creationDate | date: (isThisYear() ? 'MMMM d' : 'longDate') : (media.metadata.creationDateOffset ? media.metadata.creationDateOffset : 'UTC') }}
{{ media.metadata.creationDate | date : (media.metadata.creationDateOffset ? 'EEEE, HH:mm:ss ZZZZZ' : 'EEEE, HH:mm:ss') : (media.metadata.creationDateOffset ? media.metadata.creationDateOffset : 'UTC') }}
diff --git a/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts b/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts index fea2eb85..5c026197 100644 --- a/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts +++ b/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts @@ -148,7 +148,7 @@ export class InfoPanelLightboxComponent implements OnInit, OnChanges { isThisYear(): boolean { return ( new Date().getFullYear() === - Utils.getUTCFullYear(this.media.metadata.creationDate, this.media.metadata.creationDateOffset) + Utils.getUTCFullYear(this.media.metadata.creationDate, this.media.metadata.creationDateOffset) ); } @@ -202,4 +202,3 @@ export class InfoPanelLightboxComponent implements OnInit, OnChanges { } as TextSearch); } } - diff --git a/src/frontend/app/ui/gallery/navigator/sorting.service.ts b/src/frontend/app/ui/gallery/navigator/sorting.service.ts index 16e42d51..ffcbb202 100644 --- a/src/frontend/app/ui/gallery/navigator/sorting.service.ts +++ b/src/frontend/app/ui/gallery/navigator/sorting.service.ts @@ -150,7 +150,7 @@ export class GallerySortingService { break; case SortByTypes.Date: media.sort((a: PhotoDTO, b: PhotoDTO): number => { - return a.metadata.creationDate - b.metadata.creationDate; + return a.metadata.creationDate - b.metadata.creationDate; //TODO: Offset }); break; case SortByTypes.Rating: @@ -196,7 +196,7 @@ export class GallerySortingService { private getGroupByNameFn(grouping: GroupingMethod) { switch (grouping.method) { case SortByTypes.Date: - return (m: MediaDTO) => this.datePipe.transform(m.metadata.creationDate, 'longDate', m.metadata.creationDateOffset ? m.metadata.creationDateOffset : 'UTC'); + return (m: MediaDTO) => this.datePipe.transform(m.metadata.creationDate, 'longDate', m.metadata.creationDateOffset ? m.metadata.creationDateOffset : 'UTC'); //TODO: Offset: case SortByTypes.Name: return (m: MediaDTO) => m.name.at(0).toUpperCase(); @@ -308,7 +308,7 @@ export class GallerySortingService { if (grouping.method === GroupByTypes.Date) { // We do not need the youngest as we group by day. All photos are from the same day c.mediaGroups.forEach(g => { - g.date = Utils.makeUTCMidnight(new Date(g.media?.[0]?.metadata?.creationDate)); + g.date = Utils.makeUTCMidnight(new Date(g.media?.[0]?.metadata?.creationDate)); //TODO: Offset: }); } @@ -338,5 +338,3 @@ export interface GroupedDirectoryContent { mediaGroups: MediaGroup[]; metaFile: FileDTO[]; } - - diff --git a/test/backend/integration/model/sql/typeorm.ts b/test/backend/integration/model/sql/typeorm.ts index faa4f5b6..0bfc65a0 100644 --- a/test/backend/integration/model/sql/typeorm.ts +++ b/test/backend/integration/model/sql/typeorm.ts @@ -173,7 +173,7 @@ describe('Typeorm integration', () => { const photos = await pr .createQueryBuilder('media') - .orderBy('media.metadata.creationDate', 'ASC') + .orderBy('media.metadata.creationDate', 'ASC') //TODO: Offset: .where('media.metadata.positionData.city LIKE :text COLLATE utf8_general_ci', {text: '%' + photo.metadata.positionData.city + '%'}) .innerJoinAndSelect('media.directory', 'directory') .limit(10) @@ -195,7 +195,7 @@ describe('Typeorm integration', () => { await pr.save(photo); const photos = await pr .createQueryBuilder('media') - .orderBy('media.metadata.creationDate', 'ASC') + .orderBy('media.metadata.creationDate', 'ASC') //TODO: Offset: .where('media.metadata.positionData.city LIKE :text COLLATE utf8_general_ci', {text: '%' + city + '%'}) .innerJoinAndSelect('media.directory', 'directory') .limit(10)