fix: duplicate memories (#16432)

This commit is contained in:
Jason Rasmussen 2025-02-28 12:49:29 -05:00 committed by GitHub
parent bfcde05b1c
commit 84cf0d1670
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
} }
} }