From 102982ddf4a0ae296191a8660a91648c0da6a9a9 Mon Sep 17 00:00:00 2001 From: rikifrank Date: Tue, 31 Oct 2023 12:14:16 +0200 Subject: [PATCH] add albumThumbnailAssetId --- cli/src/api/open-api/api.ts | 6 ++++++ mobile/openapi/doc/AlbumsForPersonResponseDto.md | 1 + .../lib/model/albums_for_person_response_dto.dart | 10 +++++++++- .../test/albums_for_person_response_dto_test.dart | 5 +++++ server/immich-openapi-specs.json | 5 +++++ server/src/domain/album/album-response.dto.ts | 7 +++++-- server/src/domain/repositories/album.repository.ts | 6 ++++++ server/src/domain/repositories/person.repository.ts | 4 ++-- server/src/infra/repositories/album.repository.ts | 1 - server/src/infra/repositories/person.repository.ts | 8 +++++--- web/src/api/open-api/api.ts | 6 ++++++ 11 files changed, 50 insertions(+), 9 deletions(-) diff --git a/cli/src/api/open-api/api.ts b/cli/src/api/open-api/api.ts index 52eb844169621..17dbb54cc9c9d 100644 --- a/cli/src/api/open-api/api.ts +++ b/cli/src/api/open-api/api.ts @@ -295,6 +295,12 @@ export interface AlbumsForPersonResponseDto { * @memberof AlbumsForPersonResponseDto */ 'albumName': string; + /** + * + * @type {string} + * @memberof AlbumsForPersonResponseDto + */ + 'albumThumbnailAssetId': string; /** * * @type {number} diff --git a/mobile/openapi/doc/AlbumsForPersonResponseDto.md b/mobile/openapi/doc/AlbumsForPersonResponseDto.md index 9bbdf90f8161f..d2003fd7cc2fc 100644 --- a/mobile/openapi/doc/AlbumsForPersonResponseDto.md +++ b/mobile/openapi/doc/AlbumsForPersonResponseDto.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **albumId** | **String** | | **albumName** | **String** | | +**albumThumbnailAssetId** | **String** | | **assetCount** | **int** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/mobile/openapi/lib/model/albums_for_person_response_dto.dart b/mobile/openapi/lib/model/albums_for_person_response_dto.dart index 7c12878fd7207..0d2c570fa985f 100644 --- a/mobile/openapi/lib/model/albums_for_person_response_dto.dart +++ b/mobile/openapi/lib/model/albums_for_person_response_dto.dart @@ -15,6 +15,7 @@ class AlbumsForPersonResponseDto { AlbumsForPersonResponseDto({ required this.albumId, required this.albumName, + required this.albumThumbnailAssetId, required this.assetCount, }); @@ -22,12 +23,15 @@ class AlbumsForPersonResponseDto { String albumName; + String albumThumbnailAssetId; + int assetCount; @override bool operator ==(Object other) => identical(this, other) || other is AlbumsForPersonResponseDto && other.albumId == albumId && other.albumName == albumName && + other.albumThumbnailAssetId == albumThumbnailAssetId && other.assetCount == assetCount; @override @@ -35,15 +39,17 @@ class AlbumsForPersonResponseDto { // ignore: unnecessary_parenthesis (albumId.hashCode) + (albumName.hashCode) + + (albumThumbnailAssetId.hashCode) + (assetCount.hashCode); @override - String toString() => 'AlbumsForPersonResponseDto[albumId=$albumId, albumName=$albumName, assetCount=$assetCount]'; + String toString() => 'AlbumsForPersonResponseDto[albumId=$albumId, albumName=$albumName, albumThumbnailAssetId=$albumThumbnailAssetId, assetCount=$assetCount]'; Map toJson() { final json = {}; json[r'albumId'] = this.albumId; json[r'albumName'] = this.albumName; + json[r'albumThumbnailAssetId'] = this.albumThumbnailAssetId; json[r'assetCount'] = this.assetCount; return json; } @@ -58,6 +64,7 @@ class AlbumsForPersonResponseDto { return AlbumsForPersonResponseDto( albumId: mapValueOfType(json, r'albumId')!, albumName: mapValueOfType(json, r'albumName')!, + albumThumbnailAssetId: mapValueOfType(json, r'albumThumbnailAssetId')!, assetCount: mapValueOfType(json, r'assetCount')!, ); } @@ -108,6 +115,7 @@ class AlbumsForPersonResponseDto { static const requiredKeys = { 'albumId', 'albumName', + 'albumThumbnailAssetId', 'assetCount', }; } diff --git a/mobile/openapi/test/albums_for_person_response_dto_test.dart b/mobile/openapi/test/albums_for_person_response_dto_test.dart index fffe57e891298..df7c14f096311 100644 --- a/mobile/openapi/test/albums_for_person_response_dto_test.dart +++ b/mobile/openapi/test/albums_for_person_response_dto_test.dart @@ -26,6 +26,11 @@ void main() { // TODO }); + // String albumThumbnailAssetId + test('to test the property `albumThumbnailAssetId`', () async { + // TODO + }); + // int assetCount test('to test the property `assetCount`', () async { // TODO diff --git a/server/immich-openapi-specs.json b/server/immich-openapi-specs.json index f94481a399d81..044e520ccd33b 100644 --- a/server/immich-openapi-specs.json +++ b/server/immich-openapi-specs.json @@ -5750,6 +5750,10 @@ "albumName": { "type": "string" }, + "albumThumbnailAssetId": { + "format": "uuid", + "type": "string" + }, "assetCount": { "type": "integer" } @@ -5757,6 +5761,7 @@ "required": [ "albumId", "albumName", + "albumThumbnailAssetId", "assetCount" ], "type": "object" diff --git a/server/src/domain/album/album-response.dto.ts b/server/src/domain/album/album-response.dto.ts index 338c62ef90eaa..7d15e096bcb83 100644 --- a/server/src/domain/album/album-response.dto.ts +++ b/server/src/domain/album/album-response.dto.ts @@ -3,7 +3,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { AssetResponseDto, mapAsset } from '../asset'; import { UserResponseDto, mapUser } from '../user'; import { ValidateUUID } from '../domain.util'; -import { AlbumAssetCount } from '../repositories/album.repository'; +import { AlbumInfoAssetCount } from '../repositories/album.repository'; export class AlbumResponseDto { @@ -31,14 +31,17 @@ export class AlbumsForPersonResponseDto { albumId!: string; @ApiProperty({ type: 'string' }) albumName!: string; + @ValidateUUID() + albumThumbnailAssetId!: string; @ApiProperty({ type: 'integer' }) assetCount!: number; } -export function mapAlbumCount(entity: AlbumAssetCount): AlbumsForPersonResponseDto { +export function mapAlbumCount(entity: AlbumInfoAssetCount): AlbumsForPersonResponseDto { return { albumId: entity.albumId, albumName: entity.albumName, + albumThumbnailAssetId: entity.albumThumbnailAssetId, assetCount: entity.assetCount, }; } diff --git a/server/src/domain/repositories/album.repository.ts b/server/src/domain/repositories/album.repository.ts index 75f8b433c4e1f..7aceed277cb2d 100644 --- a/server/src/domain/repositories/album.repository.ts +++ b/server/src/domain/repositories/album.repository.ts @@ -3,8 +3,14 @@ import { AlbumEntity } from '@app/infra/entities'; export const IAlbumRepository = 'IAlbumRepository'; export interface AlbumAssetCount { + albumId: string; + assetCount: number; +} + +export interface AlbumInfoAssetCount { albumId: string; albumName: string; + albumThumbnailAssetId: string; assetCount: number; } diff --git a/server/src/domain/repositories/person.repository.ts b/server/src/domain/repositories/person.repository.ts index a0173cc8feabf..73974e2a43f26 100644 --- a/server/src/domain/repositories/person.repository.ts +++ b/server/src/domain/repositories/person.repository.ts @@ -1,5 +1,5 @@ import { AssetEntity, AssetFaceEntity, PersonEntity } from '@app/infra/entities'; -import { AlbumAssetCount } from './album.repository'; +import { AlbumInfoAssetCount } from './album.repository'; export const IPersonRepository = 'IPersonRepository'; @@ -37,7 +37,7 @@ export interface IPersonRepository { getAssets(personId: string): Promise; prepareReassignFaces(data: UpdateFacesData): Promise; reassignFaces(data: UpdateFacesData): Promise; - getAlbums(personId: string): Promise; + getAlbums(personId: string): Promise; create(entity: Partial): Promise; update(entity: Partial): Promise; diff --git a/server/src/infra/repositories/album.repository.ts b/server/src/infra/repositories/album.repository.ts index b474826402f69..69df2268593b7 100644 --- a/server/src/infra/repositories/album.repository.ts +++ b/server/src/infra/repositories/album.repository.ts @@ -77,7 +77,6 @@ export class AlbumRepository implements IAlbumRepository { return countByAlbums.map((albumCount) => ({ albumId: albumCount['album_id'], - albumName: '', assetCount: Number(albumCount['asset_count']), })); } diff --git a/server/src/infra/repositories/person.repository.ts b/server/src/infra/repositories/person.repository.ts index 2b91a42768413..4b11ed86c0b17 100644 --- a/server/src/infra/repositories/person.repository.ts +++ b/server/src/infra/repositories/person.repository.ts @@ -1,5 +1,5 @@ import { - AlbumAssetCount, + AlbumInfoAssetCount, AssetFaceId, IPersonRepository, PersonNameSearchOptions, @@ -161,11 +161,12 @@ export class PersonRepository implements IPersonRepository { }); } - async getAlbums(personId: string): Promise { + async getAlbums(personId: string): Promise { const countByAlbums = await this.albumRepository .createQueryBuilder('album') .select('album.id') .addSelect('album.albumName') + .addSelect('album.albumThumbnailAssetId') .addSelect('COUNT(asset.id)', 'asset_count') .innerJoin('album.assets', 'asset') .innerJoin('asset.faces', 'face') @@ -174,9 +175,10 @@ export class PersonRepository implements IPersonRepository { .orderBy('face.personId, album.id') .getRawMany(); - return countByAlbums.map((albumCount) => ({ + return countByAlbums.map((albumCount) => ({ albumId: albumCount['album_id'], albumName: albumCount['album_albumName'], + albumThumbnailAssetId: albumCount['album_albumThumbnailAssetId'], assetCount: Number(albumCount['asset_count']), })); } diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts index 52eb844169621..17dbb54cc9c9d 100644 --- a/web/src/api/open-api/api.ts +++ b/web/src/api/open-api/api.ts @@ -295,6 +295,12 @@ export interface AlbumsForPersonResponseDto { * @memberof AlbumsForPersonResponseDto */ 'albumName': string; + /** + * + * @type {string} + * @memberof AlbumsForPersonResponseDto + */ + 'albumThumbnailAssetId': string; /** * * @type {number}