refactor(server): album count (#2746)
* refactor(server): album count * chore: open api
This commit is contained in:
@@ -4,9 +4,9 @@ import { IAssetRepository, mapAsset } from '../asset';
|
||||
import { AuthUserDto } from '../auth';
|
||||
import { IJobRepository, JobName } from '../job';
|
||||
import { IUserRepository } from '../user';
|
||||
import { AlbumCountResponseDto, AlbumResponseDto, mapAlbum } from './album-response.dto';
|
||||
import { IAlbumRepository } from './album.repository';
|
||||
import { AddUsersDto, CreateAlbumDto, GetAlbumsDto, UpdateAlbumDto } from './dto';
|
||||
import { AlbumResponseDto, mapAlbum } from './response-dto';
|
||||
|
||||
@Injectable()
|
||||
export class AlbumService {
|
||||
@@ -17,6 +17,20 @@ export class AlbumService {
|
||||
@Inject(IUserRepository) private userRepository: IUserRepository,
|
||||
) {}
|
||||
|
||||
async getCount(authUser: AuthUserDto): Promise<AlbumCountResponseDto> {
|
||||
const [owned, shared, notShared] = await Promise.all([
|
||||
this.albumRepository.getOwned(authUser.id),
|
||||
this.albumRepository.getShared(authUser.id),
|
||||
this.albumRepository.getNotShared(authUser.id),
|
||||
]);
|
||||
|
||||
return {
|
||||
owned: owned.length,
|
||||
shared: shared.length,
|
||||
notShared: notShared.length,
|
||||
};
|
||||
}
|
||||
|
||||
async getAll({ id: ownerId }: AuthUserDto, { assetId, shared }: GetAlbumsDto): Promise<AlbumResponseDto[]> {
|
||||
await this.updateInvalidThumbnails();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user