mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor(server): move files to separate table (#11861)
This commit is contained in:
parent
af3a793fe8
commit
7af6733665
32 changed files with 403 additions and 210 deletions
|
|
@ -39,7 +39,7 @@ import { IPartnerRepository } from 'src/interfaces/partner.interface';
|
|||
import { IStackRepository } from 'src/interfaces/stack.interface';
|
||||
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
|
||||
import { IUserRepository } from 'src/interfaces/user.interface';
|
||||
import { getMyPartnerIds } from 'src/utils/asset.util';
|
||||
import { getAssetFiles, getMyPartnerIds } from 'src/utils/asset.util';
|
||||
import { usePagination } from 'src/utils/pagination';
|
||||
|
||||
export class AssetService {
|
||||
|
|
@ -71,9 +71,10 @@ export class AssetService {
|
|||
const userIds = [auth.user.id, ...partnerIds];
|
||||
|
||||
const assets = await this.assetRepository.getByDayOfYear(userIds, dto);
|
||||
const assetsWithThumbnails = assets.filter(({ files }) => !!getAssetFiles(files).thumbnailFile);
|
||||
const groups: Record<number, AssetEntity[]> = {};
|
||||
const currentYear = new Date().getFullYear();
|
||||
for (const asset of assets) {
|
||||
for (const asset of assetsWithThumbnails) {
|
||||
const yearsAgo = currentYear - asset.localDateTime.getFullYear();
|
||||
if (!groups[yearsAgo]) {
|
||||
groups[yearsAgo] = [];
|
||||
|
|
@ -126,6 +127,7 @@ export class AssetService {
|
|||
exifInfo: true,
|
||||
},
|
||||
},
|
||||
files: true,
|
||||
},
|
||||
{
|
||||
faces: {
|
||||
|
|
@ -170,6 +172,7 @@ export class AssetService {
|
|||
faces: {
|
||||
person: true,
|
||||
},
|
||||
files: true,
|
||||
});
|
||||
if (!asset) {
|
||||
throw new BadRequestException('Asset not found');
|
||||
|
|
@ -223,6 +226,7 @@ export class AssetService {
|
|||
library: true,
|
||||
stack: { assets: true },
|
||||
exifInfo: true,
|
||||
files: true,
|
||||
});
|
||||
|
||||
if (!asset) {
|
||||
|
|
@ -260,7 +264,8 @@ export class AssetService {
|
|||
}
|
||||
}
|
||||
|
||||
const files = [asset.thumbnailPath, asset.previewPath, asset.encodedVideoPath];
|
||||
const { thumbnailFile, previewFile } = getAssetFiles(asset.files);
|
||||
const files = [thumbnailFile?.path, previewFile?.path, asset.encodedVideoPath];
|
||||
if (deleteOnDisk) {
|
||||
files.push(asset.sidecarPath, asset.originalPath);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue