mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
pulled master changes
This commit is contained in:
parent
c82abf05d6
commit
73b60d0812
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
);
|
||||
|
@ -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,
|
||||
|
@ -33,7 +33,7 @@ export abstract class Messenger<C extends Record<string, unknown> = Record<strin
|
||||
if (Array.isArray(input) && input.length > 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]);
|
||||
|
@ -23,7 +23,7 @@
|
||||
<div class="col-2 align-self-center">
|
||||
{{media.metadata.fileSize | fileSize}}
|
||||
</div>
|
||||
<div class="col-3 align-self-center" [title]="media.metadata.creationDate">
|
||||
<div class="col-3 align-self-center" [title]="media.metadata.creationDate"> <!-- //TODO: Offset: -->
|
||||
{{ 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') }}
|
||||
</div>
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 '';
|
||||
|
@ -54,7 +54,7 @@
|
||||
</div>
|
||||
<div class="col-11">
|
||||
<div class="details-main">
|
||||
{{ 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') }} <!-- //TODO: Offset: -->
|
||||
</div>
|
||||
<div class="details-sub text-secondary row">
|
||||
<div class="col-12">{{ media.metadata.creationDate | date : (media.metadata.creationDateOffset ? 'EEEE, HH:mm:ss ZZZZZ' : 'EEEE, HH:mm:ss') : (media.metadata.creationDateOffset ? media.metadata.creationDateOffset : 'UTC') }}</div>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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[];
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user