e262298090
* fix(server): Split database queries based on PostgreSQL bound params limit PostgreSQL uses a 16-bit integer to indicate the number of bound parameters. This means that the maximum number of parameters for any query is 65535. Any query that tries to bind more than that (e.g. searching by a list of IDs) requires splitting the query into multiple chunks. This change includes refactoring every Repository that runs queries using a list of ids, and either flattening or merging results. Fixes #5788, #5997. Also, potentially a fix for #4648 (at least based on [this comment](https://github.com/immich-app/immich/issues/4648#issuecomment-1826134027)). References: * https://github.com/typeorm/typeorm/issues/7565 * [PostgreSQL message format - Bind](https://www.postgresql.org/docs/15/protocol-message-formats.html#PROTOCOL-MESSAGE-FORMATS-BIND) * misc: Create Chunked decorator to simplify implementation * feat: Add ChunkedArray/ChunkedSet decorators
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { AlbumEntity } from '@app/infra/entities';
|
|
|
|
export const IAlbumRepository = 'IAlbumRepository';
|
|
|
|
export interface AlbumAssetCount {
|
|
albumId: string;
|
|
assetCount: number;
|
|
startDate: Date | undefined;
|
|
endDate: Date | undefined;
|
|
}
|
|
|
|
export interface AlbumInfoOptions {
|
|
withAssets: boolean;
|
|
}
|
|
|
|
export interface AlbumAsset {
|
|
albumId: string;
|
|
assetId: string;
|
|
}
|
|
|
|
export interface AlbumAssets {
|
|
albumId: string;
|
|
assetIds: string[];
|
|
}
|
|
|
|
export interface IAlbumRepository {
|
|
getById(id: string, options: AlbumInfoOptions): Promise<AlbumEntity | null>;
|
|
getByIds(ids: string[]): Promise<AlbumEntity[]>;
|
|
getByAssetId(ownerId: string, assetId: string): Promise<AlbumEntity[]>;
|
|
addAssets(assets: AlbumAssets): Promise<void>;
|
|
getAssetIds(albumId: string, assetIds?: string[]): Promise<Set<string>>;
|
|
hasAsset(asset: AlbumAsset): Promise<boolean>;
|
|
removeAsset(assetId: string): Promise<void>;
|
|
removeAssets(albumId: string, assetIds: string[]): Promise<void>;
|
|
getMetadataForIds(ids: string[]): Promise<AlbumAssetCount[]>;
|
|
getInvalidThumbnail(): Promise<string[]>;
|
|
getOwned(ownerId: string): Promise<AlbumEntity[]>;
|
|
getShared(ownerId: string): Promise<AlbumEntity[]>;
|
|
getNotShared(ownerId: string): Promise<AlbumEntity[]>;
|
|
restoreAll(userId: string): Promise<void>;
|
|
softDeleteAll(userId: string): Promise<void>;
|
|
deleteAll(userId: string): Promise<void>;
|
|
getAll(): Promise<AlbumEntity[]>;
|
|
create(album: Partial<AlbumEntity>): Promise<AlbumEntity>;
|
|
update(album: Partial<AlbumEntity>): Promise<AlbumEntity>;
|
|
delete(album: AlbumEntity): Promise<void>;
|
|
updateThumbnails(): Promise<number | undefined>;
|
|
}
|