mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat(web): Memory (#2759)
* Add on this day * add query for x year * dev: add query * dev: front end * dev: styling * styling * more styling * add new page * navigating * navigate back and forth * styling * show gallery * fix test * fix test * show previous and next title * fix test * show up down scrolling button * more styling * styling * fix app bar * fix height of next/previous * autoplay * auto play * refactor * refactor * refactor * show date * Navigate * finish * pr feedback
This commit is contained in:
@@ -2,7 +2,9 @@ import { Inject } from '@nestjs/common';
|
||||
import { AuthUserDto } from '../auth';
|
||||
import { IAssetRepository } from './asset.repository';
|
||||
import { MapMarkerDto } from './dto/map-marker.dto';
|
||||
import { MapMarkerResponseDto } from './response-dto';
|
||||
import { MapMarkerResponseDto, mapAsset } from './response-dto';
|
||||
import { MemoryLaneResponseDto } from './response-dto/memory-lane-response.dto';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
export class AssetService {
|
||||
constructor(@Inject(IAssetRepository) private assetRepository: IAssetRepository) {}
|
||||
@@ -10,4 +12,31 @@ export class AssetService {
|
||||
getMapMarkers(authUser: AuthUserDto, options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {
|
||||
return this.assetRepository.getMapMarkers(authUser.id, options);
|
||||
}
|
||||
|
||||
async getMemoryLane(authUser: AuthUserDto, timezone: string): Promise<MemoryLaneResponseDto[]> {
|
||||
const result: MemoryLaneResponseDto[] = [];
|
||||
|
||||
const luxonDate = DateTime.fromISO(new Date().toISOString(), { zone: timezone });
|
||||
const today = new Date(luxonDate.year, luxonDate.month - 1, luxonDate.day);
|
||||
|
||||
const years = Array.from({ length: 30 }, (_, i) => {
|
||||
const year = today.getFullYear() - i - 1;
|
||||
return new Date(year, today.getMonth(), today.getDate());
|
||||
});
|
||||
|
||||
for (const year of years) {
|
||||
const assets = await this.assetRepository.getByDate(authUser.id, year);
|
||||
|
||||
if (assets.length > 0) {
|
||||
const yearGap = today.getFullYear() - year.getFullYear();
|
||||
const memory = new MemoryLaneResponseDto();
|
||||
memory.title = `${yearGap} year${yearGap > 1 && 's'} since...`;
|
||||
memory.assets = assets.map((a) => mapAsset(a));
|
||||
|
||||
result.push(memory);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user