mirror of
https://github.com/immich-app/immich.git
synced 2026-07-14 09:00:59 +00:00
feat: search by album name and id (#28672)
This commit is contained in:
parent
aecf8ec88b
commit
134c0d4dfb
6 changed files with 57 additions and 11 deletions
24
mobile/openapi/lib/api/albums_api.dart
generated
24
mobile/openapi/lib/api/albums_api.dart
generated
|
|
@ -508,12 +508,18 @@ class AlbumsApi {
|
||||||
/// * [String] assetId:
|
/// * [String] assetId:
|
||||||
/// Filter albums containing this asset ID (ignores other parameters)
|
/// Filter albums containing this asset ID (ignores other parameters)
|
||||||
///
|
///
|
||||||
|
/// * [String] id:
|
||||||
|
/// Album ID
|
||||||
|
///
|
||||||
/// * [bool] isOwned:
|
/// * [bool] isOwned:
|
||||||
/// Filter by ownership: true = only owned, false = only shared-with-me, undefined = no filter
|
/// Filter by ownership: true = only owned, false = only shared-with-me, undefined = no filter
|
||||||
///
|
///
|
||||||
/// * [bool] isShared:
|
/// * [bool] isShared:
|
||||||
/// Filter by shared status: true = only shared, false = not shared, undefined = no filter
|
/// Filter by shared status: true = only shared, false = not shared, undefined = no filter
|
||||||
Future<Response> getAllAlbumsWithHttpInfo({ String? assetId, bool? isOwned, bool? isShared, }) async {
|
///
|
||||||
|
/// * [String] name:
|
||||||
|
/// Album name (exact match)
|
||||||
|
Future<Response> getAllAlbumsWithHttpInfo({ String? assetId, String? id, bool? isOwned, bool? isShared, String? name, }) async {
|
||||||
// ignore: prefer_const_declarations
|
// ignore: prefer_const_declarations
|
||||||
final apiPath = r'/albums';
|
final apiPath = r'/albums';
|
||||||
|
|
||||||
|
|
@ -527,12 +533,18 @@ class AlbumsApi {
|
||||||
if (assetId != null) {
|
if (assetId != null) {
|
||||||
queryParams.addAll(_queryParams('', 'assetId', assetId));
|
queryParams.addAll(_queryParams('', 'assetId', assetId));
|
||||||
}
|
}
|
||||||
|
if (id != null) {
|
||||||
|
queryParams.addAll(_queryParams('', 'id', id));
|
||||||
|
}
|
||||||
if (isOwned != null) {
|
if (isOwned != null) {
|
||||||
queryParams.addAll(_queryParams('', 'isOwned', isOwned));
|
queryParams.addAll(_queryParams('', 'isOwned', isOwned));
|
||||||
}
|
}
|
||||||
if (isShared != null) {
|
if (isShared != null) {
|
||||||
queryParams.addAll(_queryParams('', 'isShared', isShared));
|
queryParams.addAll(_queryParams('', 'isShared', isShared));
|
||||||
}
|
}
|
||||||
|
if (name != null) {
|
||||||
|
queryParams.addAll(_queryParams('', 'name', name));
|
||||||
|
}
|
||||||
|
|
||||||
const contentTypes = <String>[];
|
const contentTypes = <String>[];
|
||||||
|
|
||||||
|
|
@ -557,13 +569,19 @@ class AlbumsApi {
|
||||||
/// * [String] assetId:
|
/// * [String] assetId:
|
||||||
/// Filter albums containing this asset ID (ignores other parameters)
|
/// Filter albums containing this asset ID (ignores other parameters)
|
||||||
///
|
///
|
||||||
|
/// * [String] id:
|
||||||
|
/// Album ID
|
||||||
|
///
|
||||||
/// * [bool] isOwned:
|
/// * [bool] isOwned:
|
||||||
/// Filter by ownership: true = only owned, false = only shared-with-me, undefined = no filter
|
/// Filter by ownership: true = only owned, false = only shared-with-me, undefined = no filter
|
||||||
///
|
///
|
||||||
/// * [bool] isShared:
|
/// * [bool] isShared:
|
||||||
/// Filter by shared status: true = only shared, false = not shared, undefined = no filter
|
/// Filter by shared status: true = only shared, false = not shared, undefined = no filter
|
||||||
Future<List<AlbumResponseDto>?> getAllAlbums({ String? assetId, bool? isOwned, bool? isShared, }) async {
|
///
|
||||||
final response = await getAllAlbumsWithHttpInfo( assetId: assetId, isOwned: isOwned, isShared: isShared, );
|
/// * [String] name:
|
||||||
|
/// Album name (exact match)
|
||||||
|
Future<List<AlbumResponseDto>?> getAllAlbums({ String? assetId, String? id, bool? isOwned, bool? isShared, String? name, }) async {
|
||||||
|
final response = await getAllAlbumsWithHttpInfo( assetId: assetId, id: id, isOwned: isOwned, isShared: isShared, name: name, );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1627,6 +1627,17 @@
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"description": "Album ID",
|
||||||
|
"schema": {
|
||||||
|
"format": "uuid",
|
||||||
|
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "isOwned",
|
"name": "isOwned",
|
||||||
"required": false,
|
"required": false,
|
||||||
|
|
@ -1644,6 +1655,15 @@
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"description": "Album name (exact match)",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
|
||||||
|
|
@ -3597,18 +3597,22 @@ export function getUserStatisticsAdmin({ id, isFavorite, isTrashed, visibility }
|
||||||
/**
|
/**
|
||||||
* List all albums
|
* List all albums
|
||||||
*/
|
*/
|
||||||
export function getAllAlbums({ assetId, isOwned, isShared }: {
|
export function getAllAlbums({ assetId, id, isOwned, isShared, name }: {
|
||||||
assetId?: string;
|
assetId?: string;
|
||||||
|
id?: string;
|
||||||
isOwned?: boolean;
|
isOwned?: boolean;
|
||||||
isShared?: boolean;
|
isShared?: boolean;
|
||||||
|
name?: string;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
return oazapfts.ok(oazapfts.fetchJson<{
|
return oazapfts.ok(oazapfts.fetchJson<{
|
||||||
status: 200;
|
status: 200;
|
||||||
data: AlbumResponseDto[];
|
data: AlbumResponseDto[];
|
||||||
}>(`/albums${QS.query(QS.explode({
|
}>(`/albums${QS.query(QS.explode({
|
||||||
assetId,
|
assetId,
|
||||||
|
id,
|
||||||
isOwned,
|
isOwned,
|
||||||
isShared
|
isShared,
|
||||||
|
name
|
||||||
}))}`, {
|
}))}`, {
|
||||||
...opts
|
...opts
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ const UpdateAlbumSchema = z
|
||||||
|
|
||||||
const GetAlbumsSchema = z
|
const GetAlbumsSchema = z
|
||||||
.object({
|
.object({
|
||||||
|
id: z.uuidv4().optional().describe('Album ID'),
|
||||||
|
name: z.string().optional().describe('Album name (exact match)'),
|
||||||
isOwned: stringToBool
|
isOwned: stringToBool
|
||||||
.optional()
|
.optional()
|
||||||
.describe('Filter by ownership: true = only owned, false = only shared-with-me, undefined = no filter'),
|
.describe('Filter by ownership: true = only owned, false = only shared-with-me, undefined = no filter'),
|
||||||
|
|
|
||||||
|
|
@ -209,11 +209,16 @@ export class AlbumRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenerateSql({ params: [DummyValue.UUID, { isOwned: true, isShared: true }] })
|
@GenerateSql({ params: [DummyValue.UUID, { isOwned: true, isShared: true }] })
|
||||||
getAll(ownerId: string, options: { isOwned?: boolean; isShared?: boolean } = {}): Promise<MapAlbumDto[]> {
|
getAll(
|
||||||
|
ownerId: string,
|
||||||
|
options: { id?: string; isOwned?: boolean; isShared?: boolean; name?: string } = {},
|
||||||
|
): Promise<MapAlbumDto[]> {
|
||||||
return this.buildAlbumBaseQuery(ownerId, options)
|
return this.buildAlbumBaseQuery(ownerId, options)
|
||||||
.selectAll('album')
|
.selectAll('album')
|
||||||
.select(withAlbumUsers(ownerId))
|
.select(withAlbumUsers(ownerId))
|
||||||
.select(withSharedLink)
|
.select(withSharedLink)
|
||||||
|
.$if(!!options.id, (qb) => qb.where('album.id', '=', options.id!))
|
||||||
|
.$if(!!options.name, (qb) => qb.where('album.albumName', '=', options.name!))
|
||||||
.orderBy('album.createdAt', 'desc')
|
.orderBy('album.createdAt', 'desc')
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,12 @@ export class AlbumService extends BaseService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAll(
|
async getAll({ user: { id: ownerId } }: AuthDto, { assetId, ...rest }: GetAlbumsDto): Promise<AlbumResponseDto[]> {
|
||||||
{ user: { id: ownerId } }: AuthDto,
|
|
||||||
{ assetId, isOwned, isShared }: GetAlbumsDto,
|
|
||||||
): Promise<AlbumResponseDto[]> {
|
|
||||||
await this.albumRepository.updateThumbnails();
|
await this.albumRepository.updateThumbnails();
|
||||||
|
|
||||||
const albums = assetId
|
const albums = assetId
|
||||||
? await this.albumRepository.getByAssetId(ownerId, assetId)
|
? await this.albumRepository.getByAssetId(ownerId, assetId)
|
||||||
: await this.albumRepository.getAll(ownerId, { isOwned, isShared });
|
: await this.albumRepository.getAll(ownerId, rest);
|
||||||
|
|
||||||
if (albums.length === 0) {
|
if (albums.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue