mirror of
https://github.com/immich-app/immich.git
synced 2024-12-26 10:50:29 +02:00
chore: remove unused code (#2700)
This commit is contained in:
parent
f0bc318712
commit
9a3a01ca78
@ -26,11 +26,7 @@ export interface IAssetRepository {
|
|||||||
asset: Omit<AssetEntity, 'id' | 'createdAt' | 'updatedAt' | 'ownerId' | 'livePhotoVideoId'>,
|
asset: Omit<AssetEntity, 'id' | 'createdAt' | 'updatedAt' | 'ownerId' | 'livePhotoVideoId'>,
|
||||||
): Promise<AssetEntity>;
|
): Promise<AssetEntity>;
|
||||||
remove(asset: AssetEntity): Promise<void>;
|
remove(asset: AssetEntity): Promise<void>;
|
||||||
save(asset: Partial<AssetEntity>): Promise<AssetEntity>;
|
|
||||||
|
|
||||||
update(userId: string, asset: AssetEntity, dto: UpdateAssetDto): Promise<AssetEntity>;
|
update(userId: string, asset: AssetEntity, dto: UpdateAssetDto): Promise<AssetEntity>;
|
||||||
getAll(): Promise<AssetEntity[]>;
|
|
||||||
getAllVideos(): Promise<AssetEntity[]>;
|
|
||||||
getAllByUserId(userId: string, dto: AssetSearchDto): Promise<AssetEntity[]>;
|
getAllByUserId(userId: string, dto: AssetSearchDto): Promise<AssetEntity[]>;
|
||||||
getAllByDeviceId(userId: string, deviceId: string): Promise<string[]>;
|
getAllByDeviceId(userId: string, deviceId: string): Promise<string[]>;
|
||||||
getById(assetId: string): Promise<AssetEntity>;
|
getById(assetId: string): Promise<AssetEntity>;
|
||||||
@ -55,22 +51,6 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
@InjectRepository(ExifEntity) private exifRepository: Repository<ExifEntity>,
|
@InjectRepository(ExifEntity) private exifRepository: Repository<ExifEntity>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async getAllVideos(): Promise<AssetEntity[]> {
|
|
||||||
return await this.assetRepository.find({
|
|
||||||
where: { type: AssetType.VIDEO },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getAll(): Promise<AssetEntity[]> {
|
|
||||||
return await this.assetRepository.find({
|
|
||||||
where: { isVisible: true },
|
|
||||||
relations: {
|
|
||||||
exifInfo: true,
|
|
||||||
smartInfo: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getAssetCountByUserId(ownerId: string): Promise<AssetCountByUserIdResponseDto> {
|
async getAssetCountByUserId(ownerId: string): Promise<AssetCountByUserIdResponseDto> {
|
||||||
// Get asset count by AssetType
|
// Get asset count by AssetType
|
||||||
const items = await this.assetRepository
|
const items = await this.assetRepository
|
||||||
@ -151,8 +131,8 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
return builder.getRawMany();
|
return builder.getRawMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSearchPropertiesByUserId(userId: string): Promise<SearchPropertiesDto[]> {
|
getSearchPropertiesByUserId(userId: string): Promise<SearchPropertiesDto[]> {
|
||||||
return await this.assetRepository
|
return this.assetRepository
|
||||||
.createQueryBuilder('asset')
|
.createQueryBuilder('asset')
|
||||||
.where('asset.ownerId = :userId', { userId: userId })
|
.where('asset.ownerId = :userId', { userId: userId })
|
||||||
.andWhere('asset.isVisible = true')
|
.andWhere('asset.isVisible = true')
|
||||||
@ -172,8 +152,8 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
.getRawMany();
|
.getRawMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDetectedObjectsByUserId(userId: string): Promise<CuratedObjectsResponseDto[]> {
|
getDetectedObjectsByUserId(userId: string): Promise<CuratedObjectsResponseDto[]> {
|
||||||
return await this.assetRepository.query(
|
return this.assetRepository.query(
|
||||||
`
|
`
|
||||||
SELECT DISTINCT ON (unnest(si.objects)) a.id, unnest(si.objects) as "object", a."resizePath", a."deviceAssetId", a."deviceId"
|
SELECT DISTINCT ON (unnest(si.objects)) a.id, unnest(si.objects) as "object", a."resizePath", a."deviceAssetId", a."deviceId"
|
||||||
FROM assets a
|
FROM assets a
|
||||||
@ -186,8 +166,8 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLocationsByUserId(userId: string): Promise<CuratedLocationsResponseDto[]> {
|
getLocationsByUserId(userId: string): Promise<CuratedLocationsResponseDto[]> {
|
||||||
return await this.assetRepository.query(
|
return this.assetRepository.query(
|
||||||
`
|
`
|
||||||
SELECT DISTINCT ON (e.city) a.id, e.city, a."resizePath", a."deviceAssetId", a."deviceId"
|
SELECT DISTINCT ON (e.city) a.id, e.city, a."resizePath", a."deviceAssetId", a."deviceId"
|
||||||
FROM assets a
|
FROM assets a
|
||||||
@ -206,8 +186,8 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
* - include exif info
|
* - include exif info
|
||||||
* @param assetId
|
* @param assetId
|
||||||
*/
|
*/
|
||||||
async getById(assetId: string): Promise<AssetEntity> {
|
getById(assetId: string): Promise<AssetEntity> {
|
||||||
return await this.assetRepository.findOneOrFail({
|
return this.assetRepository.findOneOrFail({
|
||||||
where: {
|
where: {
|
||||||
id: assetId,
|
id: assetId,
|
||||||
},
|
},
|
||||||
@ -227,7 +207,7 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
* Get all assets belong to the user on the database
|
* Get all assets belong to the user on the database
|
||||||
* @param ownerId
|
* @param ownerId
|
||||||
*/
|
*/
|
||||||
async getAllByUserId(ownerId: string, dto: AssetSearchDto): Promise<AssetEntity[]> {
|
getAllByUserId(ownerId: string, dto: AssetSearchDto): Promise<AssetEntity[]> {
|
||||||
return this.assetRepository.find({
|
return this.assetRepository.find({
|
||||||
where: {
|
where: {
|
||||||
ownerId,
|
ownerId,
|
||||||
@ -258,7 +238,7 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(
|
create(
|
||||||
asset: Omit<AssetEntity, 'id' | 'createdAt' | 'updatedAt' | 'ownerId' | 'livePhotoVideoId'>,
|
asset: Omit<AssetEntity, 'id' | 'createdAt' | 'updatedAt' | 'ownerId' | 'livePhotoVideoId'>,
|
||||||
): Promise<AssetEntity> {
|
): Promise<AssetEntity> {
|
||||||
return this.assetRepository.save(asset);
|
return this.assetRepository.save(asset);
|
||||||
@ -268,11 +248,6 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
await this.assetRepository.remove(asset);
|
await this.assetRepository.remove(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
async save(asset: Partial<AssetEntity>): Promise<AssetEntity> {
|
|
||||||
const { id } = await this.assetRepository.save(asset);
|
|
||||||
return this.assetRepository.findOneOrFail({ where: { id } });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update asset
|
* Update asset
|
||||||
*/
|
*/
|
||||||
@ -329,7 +304,7 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
* @param checksums
|
* @param checksums
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async getAssetsByChecksums(ownerId: string, checksums: Buffer[]): Promise<AssetCheck[]> {
|
getAssetsByChecksums(ownerId: string, checksums: Buffer[]): Promise<AssetCheck[]> {
|
||||||
return this.assetRepository.find({
|
return this.assetRepository.find({
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
@ -354,8 +329,8 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
return assets.map((asset) => asset.deviceAssetId);
|
return assets.map((asset) => asset.deviceAssetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async countByIdAndUser(assetId: string, ownerId: string): Promise<number> {
|
countByIdAndUser(assetId: string, ownerId: string): Promise<number> {
|
||||||
return await this.assetRepository.count({
|
return this.assetRepository.count({
|
||||||
where: {
|
where: {
|
||||||
id: assetId,
|
id: assetId,
|
||||||
ownerId,
|
ownerId,
|
||||||
|
@ -146,11 +146,8 @@ describe('AssetService', () => {
|
|||||||
get: jest.fn(),
|
get: jest.fn(),
|
||||||
create: jest.fn(),
|
create: jest.fn(),
|
||||||
remove: jest.fn(),
|
remove: jest.fn(),
|
||||||
save: jest.fn(),
|
|
||||||
|
|
||||||
update: jest.fn(),
|
update: jest.fn(),
|
||||||
getAll: jest.fn(),
|
|
||||||
getAllVideos: jest.fn(),
|
|
||||||
getAllByUserId: jest.fn(),
|
getAllByUserId: jest.fn(),
|
||||||
getAllByDeviceId: jest.fn(),
|
getAllByDeviceId: jest.fn(),
|
||||||
getAssetCountByTimeBucket: jest.fn(),
|
getAssetCountByTimeBucket: jest.fn(),
|
||||||
@ -283,7 +280,6 @@ describe('AssetService', () => {
|
|||||||
const dto = _getCreateAssetDto();
|
const dto = _getCreateAssetDto();
|
||||||
|
|
||||||
assetRepositoryMock.create.mockResolvedValue(assetEntity);
|
assetRepositoryMock.create.mockResolvedValue(assetEntity);
|
||||||
assetRepositoryMock.save.mockResolvedValue(assetEntity);
|
|
||||||
|
|
||||||
await expect(sut.uploadFile(authStub.user1, dto, file)).resolves.toEqual({ duplicate: false, id: 'id_1' });
|
await expect(sut.uploadFile(authStub.user1, dto, file)).resolves.toEqual({ duplicate: false, id: 'id_1' });
|
||||||
|
|
||||||
@ -319,9 +315,7 @@ describe('AssetService', () => {
|
|||||||
(error as any).constraint = 'UQ_userid_checksum';
|
(error as any).constraint = 'UQ_userid_checksum';
|
||||||
|
|
||||||
assetRepositoryMock.create.mockResolvedValueOnce(assetEntityStub.livePhotoMotionAsset);
|
assetRepositoryMock.create.mockResolvedValueOnce(assetEntityStub.livePhotoMotionAsset);
|
||||||
assetRepositoryMock.save.mockResolvedValueOnce(assetEntityStub.livePhotoMotionAsset);
|
|
||||||
assetRepositoryMock.create.mockResolvedValueOnce(assetEntityStub.livePhotoStillAsset);
|
assetRepositoryMock.create.mockResolvedValueOnce(assetEntityStub.livePhotoStillAsset);
|
||||||
assetRepositoryMock.save.mockResolvedValueOnce(assetEntityStub.livePhotoStillAsset);
|
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
sut.uploadFile(authStub.user1, dto, fileStub.livePhotoStill, fileStub.livePhotoMotion),
|
sut.uploadFile(authStub.user1, dto, fileStub.livePhotoStill, fileStub.livePhotoMotion),
|
||||||
|
Loading…
Reference in New Issue
Block a user