mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
fix: duplicate memories (#16432)
This commit is contained in:
parent
bfcde05b1c
commit
84cf0d1670
@ -30,20 +30,18 @@ export class MemoryService extends BaseService {
|
|||||||
const start = DateTime.utc().startOf('day').minus({ days: DAYS });
|
const start = DateTime.utc().startOf('day').minus({ days: DAYS });
|
||||||
|
|
||||||
const state = await this.systemMetadataRepository.get(SystemMetadataKey.MEMORIES_STATE);
|
const state = await this.systemMetadataRepository.get(SystemMetadataKey.MEMORIES_STATE);
|
||||||
let lastOnThisDayDate = state?.lastOnThisDayDate ? DateTime.fromISO(state?.lastOnThisDayDate) : start;
|
const lastOnThisDayDate = state?.lastOnThisDayDate ? DateTime.fromISO(state.lastOnThisDayDate) : start;
|
||||||
|
|
||||||
// generate a memory +/- X days from today
|
// generate a memory +/- X days from today
|
||||||
for (let i = 0; i <= DAYS * 2 + 1; i++) {
|
for (let i = 0; i <= DAYS * 2; i++) {
|
||||||
const target = start.plus({ days: i });
|
const target = start.plus({ days: i });
|
||||||
if (lastOnThisDayDate > target) {
|
if (lastOnThisDayDate >= target) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const showAt = target.startOf('day').toISO();
|
const showAt = target.startOf('day').toISO();
|
||||||
const hideAt = target.endOf('day').toISO();
|
const hideAt = target.endOf('day').toISO();
|
||||||
|
|
||||||
this.logger.log(`Creating memories for month=${target.month}, day=${target.day}`);
|
|
||||||
|
|
||||||
for (const [userId, userIds] of Object.entries(userMap)) {
|
for (const [userId, userIds] of Object.entries(userMap)) {
|
||||||
const memories = await this.assetRepository.getByDayOfYear(userIds, target);
|
const memories = await this.assetRepository.getByDayOfYear(userIds, target);
|
||||||
|
|
||||||
@ -67,8 +65,6 @@ export class MemoryService extends BaseService {
|
|||||||
...state,
|
...state,
|
||||||
lastOnThisDayDate: target.toISO(),
|
lastOnThisDayDate: target.toISO(),
|
||||||
});
|
});
|
||||||
|
|
||||||
lastOnThisDayDate = target;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user