diff --git a/cli/src/api/open-api/api.ts b/cli/src/api/open-api/api.ts index 48977baf7c6e1..52eb844169621 100644 --- a/cli/src/api/open-api/api.ts +++ b/cli/src/api/open-api/api.ts @@ -289,6 +289,12 @@ export interface AlbumsForPersonResponseDto { * @memberof AlbumsForPersonResponseDto */ 'albumId': string; + /** + * + * @type {string} + * @memberof AlbumsForPersonResponseDto + */ + 'albumName': string; /** * * @type {number} diff --git a/mobile/openapi/doc/AlbumsForPersonResponseDto.md b/mobile/openapi/doc/AlbumsForPersonResponseDto.md index 1dcee6b42fbca..9bbdf90f8161f 100644 --- a/mobile/openapi/doc/AlbumsForPersonResponseDto.md +++ b/mobile/openapi/doc/AlbumsForPersonResponseDto.md @@ -9,6 +9,7 @@ import 'package:openapi/api.dart'; Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **albumId** | **String** | | +**albumName** | **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 cb917e852260a..7c12878fd7207 100644 --- a/mobile/openapi/lib/model/albums_for_person_response_dto.dart +++ b/mobile/openapi/lib/model/albums_for_person_response_dto.dart @@ -14,30 +14,36 @@ class AlbumsForPersonResponseDto { /// Returns a new [AlbumsForPersonResponseDto] instance. AlbumsForPersonResponseDto({ required this.albumId, + required this.albumName, required this.assetCount, }); String albumId; + String albumName; + int assetCount; @override bool operator ==(Object other) => identical(this, other) || other is AlbumsForPersonResponseDto && other.albumId == albumId && + other.albumName == albumName && other.assetCount == assetCount; @override int get hashCode => // ignore: unnecessary_parenthesis (albumId.hashCode) + + (albumName.hashCode) + (assetCount.hashCode); @override - String toString() => 'AlbumsForPersonResponseDto[albumId=$albumId, assetCount=$assetCount]'; + String toString() => 'AlbumsForPersonResponseDto[albumId=$albumId, albumName=$albumName, assetCount=$assetCount]'; Map toJson() { final json = {}; json[r'albumId'] = this.albumId; + json[r'albumName'] = this.albumName; json[r'assetCount'] = this.assetCount; return json; } @@ -51,6 +57,7 @@ class AlbumsForPersonResponseDto { return AlbumsForPersonResponseDto( albumId: mapValueOfType(json, r'albumId')!, + albumName: mapValueOfType(json, r'albumName')!, assetCount: mapValueOfType(json, r'assetCount')!, ); } @@ -100,6 +107,7 @@ class AlbumsForPersonResponseDto { /// The list of required keys that must be present in a JSON. static const requiredKeys = { 'albumId', + 'albumName', '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 0eaa0ada1a706..fffe57e891298 100644 --- a/mobile/openapi/test/albums_for_person_response_dto_test.dart +++ b/mobile/openapi/test/albums_for_person_response_dto_test.dart @@ -21,6 +21,11 @@ void main() { // TODO }); + // String albumName + test('to test the property `albumName`', () 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 dc335c4101eed..f94481a399d81 100644 --- a/server/immich-openapi-specs.json +++ b/server/immich-openapi-specs.json @@ -5747,12 +5747,16 @@ "format": "uuid", "type": "string" }, + "albumName": { + "type": "string" + }, "assetCount": { "type": "integer" } }, "required": [ "albumId", + "albumName", "assetCount" ], "type": "object" diff --git a/server/src/domain/album/album-response.dto.ts b/server/src/domain/album/album-response.dto.ts index 4a05b6efce72c..338c62ef90eaa 100644 --- a/server/src/domain/album/album-response.dto.ts +++ b/server/src/domain/album/album-response.dto.ts @@ -29,6 +29,8 @@ export class AlbumResponseDto { export class AlbumsForPersonResponseDto { @ValidateUUID() albumId!: string; + @ApiProperty({ type: 'string' }) + albumName!: string; @ApiProperty({ type: 'integer' }) assetCount!: number; } @@ -36,6 +38,7 @@ export class AlbumsForPersonResponseDto { export function mapAlbumCount(entity: AlbumAssetCount): AlbumsForPersonResponseDto { return { albumId: entity.albumId, + albumName: entity.albumName, assetCount: entity.assetCount, }; } diff --git a/server/src/domain/repositories/album.repository.ts b/server/src/domain/repositories/album.repository.ts index d3ca62da12487..75f8b433c4e1f 100644 --- a/server/src/domain/repositories/album.repository.ts +++ b/server/src/domain/repositories/album.repository.ts @@ -4,6 +4,7 @@ export const IAlbumRepository = 'IAlbumRepository'; export interface AlbumAssetCount { albumId: string; + albumName: string; assetCount: number; } diff --git a/server/src/infra/repositories/album.repository.ts b/server/src/infra/repositories/album.repository.ts index 69df2268593b7..b474826402f69 100644 --- a/server/src/infra/repositories/album.repository.ts +++ b/server/src/infra/repositories/album.repository.ts @@ -77,6 +77,7 @@ 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 9282b35536827..fa903f9676b79 100644 --- a/server/src/infra/repositories/person.repository.ts +++ b/server/src/infra/repositories/person.repository.ts @@ -165,17 +165,18 @@ export class PersonRepository implements IPersonRepository { const countByAlbums = await this.albumRepository .createQueryBuilder('album') .select('album.id') - .addSelect('COUNT(albums_assets.assetsId)', 'asset_count') - .innerJoin('albums_assets_assets', 'albums_assets', 'albums_assets.albumsId = album.id') - .innerJoin('asset_faces', 'asset_faces', 'asset_faces.assetId = albums_assets.assetId') - .innerJoin('person', 'person', 'asset_faces.personId = person.id') - .where('person.id = :personId', { personId }) - .groupBy('person.id, album.name') - .orderBy('person.id, album.name') + .addSelect('album.albumName') + .addSelect('COUNT(asset.id)', 'asset_count') + .innerJoin('album.assets', 'asset') + .innerJoin('asset.faces', 'face') + .where('face.personId = :personId', { personId }) + .groupBy('face.personId, album.id') + .orderBy('face.personId, album.id') .getRawMany(); return countByAlbums.map((albumCount) => ({ albumId: albumCount['album_id'], + albumName: albumCount['album_name'], assetCount: Number(albumCount['asset_count']), })); } diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts index 48977baf7c6e1..52eb844169621 100644 --- a/web/src/api/open-api/api.ts +++ b/web/src/api/open-api/api.ts @@ -289,6 +289,12 @@ export interface AlbumsForPersonResponseDto { * @memberof AlbumsForPersonResponseDto */ 'albumId': string; + /** + * + * @type {string} + * @memberof AlbumsForPersonResponseDto + */ + 'albumName': string; /** * * @type {number}