mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
fix: memory lane assets in ascending order (#8309)
* fix: memory lane asset order * chore: deprecate title * chore: open-api * chore: rename years => yearsAgo
This commit is contained in:
parent
13b11a39a9
commit
9fe80c25eb
12 changed files with 65 additions and 29 deletions
|
|
@ -174,20 +174,25 @@ export class AssetService {
|
|||
userIds.push(...partnersIds);
|
||||
|
||||
const assets = await this.assetRepository.getByDayOfYear(userIds, dto);
|
||||
const groups: Record<number, AssetEntity[]> = {};
|
||||
for (const asset of assets) {
|
||||
const yearsAgo = currentYear - asset.localDateTime.getFullYear();
|
||||
if (!groups[yearsAgo]) {
|
||||
groups[yearsAgo] = [];
|
||||
}
|
||||
groups[yearsAgo].push(asset);
|
||||
}
|
||||
|
||||
return _.chain(assets)
|
||||
.filter((asset) => asset.localDateTime.getFullYear() < currentYear)
|
||||
.map((asset) => {
|
||||
const years = currentYear - asset.localDateTime.getFullYear();
|
||||
|
||||
return {
|
||||
title: `${years} year${years > 1 ? 's' : ''} since...`,
|
||||
asset: mapAsset(asset, { auth }),
|
||||
};
|
||||
})
|
||||
.groupBy((asset) => asset.title)
|
||||
.map((items, title) => ({ title, assets: items.map(({ asset }) => asset) }))
|
||||
.value();
|
||||
return Object.keys(groups)
|
||||
.map(Number)
|
||||
.sort()
|
||||
.filter((yearsAgo) => yearsAgo > 0)
|
||||
.map((yearsAgo) => ({
|
||||
yearsAgo,
|
||||
// TODO move this to clients
|
||||
title: `${yearsAgo} year${yearsAgo > 1 ? 's' : ''} since...`,
|
||||
assets: groups[yearsAgo].map((asset) => mapAsset(asset, { auth })),
|
||||
}));
|
||||
}
|
||||
|
||||
private async timeBucketChecks(auth: AuthDto, dto: TimeBucketDto) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue