1
0
mirror of https://github.com/immich-app/immich.git synced 2025-04-25 13:24:51 +02:00

refactor(server): album count (#2746)

* refactor(server): album count

* chore: open api
This commit is contained in:
Jason Rasmussen 2023-06-16 11:48:48 -04:00 committed by GitHub
parent 441ee2ef90
commit 07f7fffae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 100 additions and 95 deletions

View File

@ -83,7 +83,7 @@ Class | Method | HTTP request | Description
*AlbumApi* | [**createAlbumSharedLink**](doc//AlbumApi.md#createalbumsharedlink) | **POST** /album/create-shared-link | *AlbumApi* | [**createAlbumSharedLink**](doc//AlbumApi.md#createalbumsharedlink) | **POST** /album/create-shared-link |
*AlbumApi* | [**deleteAlbum**](doc//AlbumApi.md#deletealbum) | **DELETE** /album/{id} | *AlbumApi* | [**deleteAlbum**](doc//AlbumApi.md#deletealbum) | **DELETE** /album/{id} |
*AlbumApi* | [**downloadArchive**](doc//AlbumApi.md#downloadarchive) | **GET** /album/{id}/download | *AlbumApi* | [**downloadArchive**](doc//AlbumApi.md#downloadarchive) | **GET** /album/{id}/download |
*AlbumApi* | [**getAlbumCountByUserId**](doc//AlbumApi.md#getalbumcountbyuserid) | **GET** /album/count-by-user-id | *AlbumApi* | [**getAlbumCount**](doc//AlbumApi.md#getalbumcount) | **GET** /album/count |
*AlbumApi* | [**getAlbumInfo**](doc//AlbumApi.md#getalbuminfo) | **GET** /album/{id} | *AlbumApi* | [**getAlbumInfo**](doc//AlbumApi.md#getalbuminfo) | **GET** /album/{id} |
*AlbumApi* | [**getAllAlbums**](doc//AlbumApi.md#getallalbums) | **GET** /album | *AlbumApi* | [**getAllAlbums**](doc//AlbumApi.md#getallalbums) | **GET** /album |
*AlbumApi* | [**removeAssetFromAlbum**](doc//AlbumApi.md#removeassetfromalbum) | **DELETE** /album/{id}/assets | *AlbumApi* | [**removeAssetFromAlbum**](doc//AlbumApi.md#removeassetfromalbum) | **DELETE** /album/{id}/assets |

View File

@ -15,7 +15,7 @@ Method | HTTP request | Description
[**createAlbumSharedLink**](AlbumApi.md#createalbumsharedlink) | **POST** /album/create-shared-link | [**createAlbumSharedLink**](AlbumApi.md#createalbumsharedlink) | **POST** /album/create-shared-link |
[**deleteAlbum**](AlbumApi.md#deletealbum) | **DELETE** /album/{id} | [**deleteAlbum**](AlbumApi.md#deletealbum) | **DELETE** /album/{id} |
[**downloadArchive**](AlbumApi.md#downloadarchive) | **GET** /album/{id}/download | [**downloadArchive**](AlbumApi.md#downloadarchive) | **GET** /album/{id}/download |
[**getAlbumCountByUserId**](AlbumApi.md#getalbumcountbyuserid) | **GET** /album/count-by-user-id | [**getAlbumCount**](AlbumApi.md#getalbumcount) | **GET** /album/count |
[**getAlbumInfo**](AlbumApi.md#getalbuminfo) | **GET** /album/{id} | [**getAlbumInfo**](AlbumApi.md#getalbuminfo) | **GET** /album/{id} |
[**getAllAlbums**](AlbumApi.md#getallalbums) | **GET** /album | [**getAllAlbums**](AlbumApi.md#getallalbums) | **GET** /album |
[**removeAssetFromAlbum**](AlbumApi.md#removeassetfromalbum) | **DELETE** /album/{id}/assets | [**removeAssetFromAlbum**](AlbumApi.md#removeassetfromalbum) | **DELETE** /album/{id}/assets |
@ -364,8 +364,8 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **getAlbumCountByUserId** # **getAlbumCount**
> AlbumCountResponseDto getAlbumCountByUserId() > AlbumCountResponseDto getAlbumCount()
@ -390,10 +390,10 @@ import 'package:openapi/api.dart';
final api_instance = AlbumApi(); final api_instance = AlbumApi();
try { try {
final result = api_instance.getAlbumCountByUserId(); final result = api_instance.getAlbumCount();
print(result); print(result);
} catch (e) { } catch (e) {
print('Exception when calling AlbumApi->getAlbumCountByUserId: $e\n'); print('Exception when calling AlbumApi->getAlbumCount: $e\n');
} }
``` ```

View File

@ -10,7 +10,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**owned** | **int** | | **owned** | **int** | |
**shared** | **int** | | **shared** | **int** | |
**sharing** | **int** | | **notShared** | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -332,10 +332,10 @@ class AlbumApi {
return null; return null;
} }
/// Performs an HTTP 'GET /album/count-by-user-id' operation and returns the [Response]. /// Performs an HTTP 'GET /album/count' operation and returns the [Response].
Future<Response> getAlbumCountByUserIdWithHttpInfo() async { Future<Response> getAlbumCountWithHttpInfo() async {
// ignore: prefer_const_declarations // ignore: prefer_const_declarations
final path = r'/album/count-by-user-id'; final path = r'/album/count';
// ignore: prefer_final_locals // ignore: prefer_final_locals
Object? postBody; Object? postBody;
@ -358,8 +358,8 @@ class AlbumApi {
); );
} }
Future<AlbumCountResponseDto?> getAlbumCountByUserId() async { Future<AlbumCountResponseDto?> getAlbumCount() async {
final response = await getAlbumCountByUserIdWithHttpInfo(); final response = await getAlbumCountWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response)); throw ApiException(response.statusCode, await _decodeBodyBytes(response));
} }

View File

@ -15,36 +15,36 @@ class AlbumCountResponseDto {
AlbumCountResponseDto({ AlbumCountResponseDto({
required this.owned, required this.owned,
required this.shared, required this.shared,
required this.sharing, required this.notShared,
}); });
int owned; int owned;
int shared; int shared;
int sharing; int notShared;
@override @override
bool operator ==(Object other) => identical(this, other) || other is AlbumCountResponseDto && bool operator ==(Object other) => identical(this, other) || other is AlbumCountResponseDto &&
other.owned == owned && other.owned == owned &&
other.shared == shared && other.shared == shared &&
other.sharing == sharing; other.notShared == notShared;
@override @override
int get hashCode => int get hashCode =>
// ignore: unnecessary_parenthesis // ignore: unnecessary_parenthesis
(owned.hashCode) + (owned.hashCode) +
(shared.hashCode) + (shared.hashCode) +
(sharing.hashCode); (notShared.hashCode);
@override @override
String toString() => 'AlbumCountResponseDto[owned=$owned, shared=$shared, sharing=$sharing]'; String toString() => 'AlbumCountResponseDto[owned=$owned, shared=$shared, notShared=$notShared]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
json[r'owned'] = this.owned; json[r'owned'] = this.owned;
json[r'shared'] = this.shared; json[r'shared'] = this.shared;
json[r'sharing'] = this.sharing; json[r'notShared'] = this.notShared;
return json; return json;
} }
@ -69,7 +69,7 @@ class AlbumCountResponseDto {
return AlbumCountResponseDto( return AlbumCountResponseDto(
owned: mapValueOfType<int>(json, r'owned')!, owned: mapValueOfType<int>(json, r'owned')!,
shared: mapValueOfType<int>(json, r'shared')!, shared: mapValueOfType<int>(json, r'shared')!,
sharing: mapValueOfType<int>(json, r'sharing')!, notShared: mapValueOfType<int>(json, r'notShared')!,
); );
} }
return null; return null;
@ -119,7 +119,7 @@ class AlbumCountResponseDto {
static const requiredKeys = <String>{ static const requiredKeys = <String>{
'owned', 'owned',
'shared', 'shared',
'sharing', 'notShared',
}; };
} }

View File

@ -47,8 +47,8 @@ void main() {
// TODO // TODO
}); });
//Future<AlbumCountResponseDto> getAlbumCountByUserId() async //Future<AlbumCountResponseDto> getAlbumCount() async
test('test getAlbumCountByUserId', () async { test('test getAlbumCount', () async {
// TODO // TODO
}); });

View File

@ -26,8 +26,8 @@ void main() {
// TODO // TODO
}); });
// int sharing // int notShared
test('to test the property `sharing`', () async { test('to test the property `notShared`', () async {
// TODO // TODO
}); });

View File

@ -95,9 +95,9 @@
] ]
} }
}, },
"/album/count-by-user-id": { "/album/count": {
"get": { "get": {
"operationId": "getAlbumCountByUserId", "operationId": "getAlbumCount",
"parameters": [], "parameters": [],
"responses": { "responses": {
"200": { "200": {
@ -4530,14 +4530,14 @@
"shared": { "shared": {
"type": "integer" "type": "integer"
}, },
"sharing": { "notShared": {
"type": "integer" "type": "integer"
} }
}, },
"required": [ "required": [
"owned", "owned",
"shared", "shared",
"sharing" "notShared"
] ]
}, },
"AlbumResponseDto": { "AlbumResponseDto": {

View File

@ -1,7 +1,7 @@
import { AlbumEntity } from '@app/infra/entities'; import { AlbumEntity } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { AssetResponseDto, mapAsset } from '../../asset'; import { AssetResponseDto, mapAsset } from '../asset';
import { mapUser, UserResponseDto } from '../../user'; import { mapUser, UserResponseDto } from '../user';
export class AlbumResponseDto { export class AlbumResponseDto {
id!: string; id!: string;
@ -63,3 +63,14 @@ export function mapAlbumExcludeAssetInfo(entity: AlbumEntity): AlbumResponseDto
assetCount: entity.assets?.length || 0, assetCount: entity.assets?.length || 0,
}; };
} }
export class AlbumCountResponseDto {
@ApiProperty({ type: 'integer' })
owned!: number;
@ApiProperty({ type: 'integer' })
shared!: number;
@ApiProperty({ type: 'integer' })
notShared!: number;
}

View File

@ -35,6 +35,23 @@ describe(AlbumService.name, () => {
expect(sut).toBeDefined(); expect(sut).toBeDefined();
}); });
describe('getCount', () => {
it('should get the album count', async () => {
albumMock.getOwned.mockResolvedValue([]),
albumMock.getShared.mockResolvedValue([]),
albumMock.getNotShared.mockResolvedValue([]),
await expect(sut.getCount(authStub.admin)).resolves.toEqual({
owned: 0,
shared: 0,
notShared: 0,
});
expect(albumMock.getOwned).toHaveBeenCalledWith(authStub.admin.id);
expect(albumMock.getShared).toHaveBeenCalledWith(authStub.admin.id);
expect(albumMock.getNotShared).toHaveBeenCalledWith(authStub.admin.id);
});
});
describe('getAll', () => { describe('getAll', () => {
it('gets list of albums for auth user', async () => { it('gets list of albums for auth user', async () => {
albumMock.getOwned.mockResolvedValue([albumStub.empty, albumStub.sharedWithUser]); albumMock.getOwned.mockResolvedValue([albumStub.empty, albumStub.sharedWithUser]);

View File

@ -4,9 +4,9 @@ import { IAssetRepository, mapAsset } from '../asset';
import { AuthUserDto } from '../auth'; import { AuthUserDto } from '../auth';
import { IJobRepository, JobName } from '../job'; import { IJobRepository, JobName } from '../job';
import { IUserRepository } from '../user'; import { IUserRepository } from '../user';
import { AlbumCountResponseDto, AlbumResponseDto, mapAlbum } from './album-response.dto';
import { IAlbumRepository } from './album.repository'; import { IAlbumRepository } from './album.repository';
import { AddUsersDto, CreateAlbumDto, GetAlbumsDto, UpdateAlbumDto } from './dto'; import { AddUsersDto, CreateAlbumDto, GetAlbumsDto, UpdateAlbumDto } from './dto';
import { AlbumResponseDto, mapAlbum } from './response-dto';
@Injectable() @Injectable()
export class AlbumService { export class AlbumService {
@ -17,6 +17,20 @@ export class AlbumService {
@Inject(IUserRepository) private userRepository: IUserRepository, @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[]> { async getAll({ id: ownerId }: AuthUserDto, { assetId, shared }: GetAlbumsDto): Promise<AlbumResponseDto[]> {
await this.updateInvalidThumbnails(); await this.updateInvalidThumbnails();

View File

@ -1,4 +1,4 @@
export * from './album-response.dto';
export * from './album.repository'; export * from './album.repository';
export * from './album.service'; export * from './album.service';
export * from './dto'; export * from './dto';
export * from './response-dto';

View File

@ -1 +0,0 @@
export * from './album-response.dto';

View File

@ -5,7 +5,6 @@ import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import { AddAssetsDto } from './dto/add-assets.dto'; import { AddAssetsDto } from './dto/add-assets.dto';
import { RemoveAssetsDto } from './dto/remove-assets.dto'; import { RemoveAssetsDto } from './dto/remove-assets.dto';
import { AlbumCountResponseDto } from './response-dto/album-count-response.dto';
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto'; import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto';
export interface IAlbumRepository { export interface IAlbumRepository {
@ -13,7 +12,6 @@ export interface IAlbumRepository {
removeAssets(album: AlbumEntity, removeAssets: RemoveAssetsDto): Promise<number>; removeAssets(album: AlbumEntity, removeAssets: RemoveAssetsDto): Promise<number>;
addAssets(album: AlbumEntity, addAssetsDto: AddAssetsDto): Promise<AddAssetsResponseDto>; addAssets(album: AlbumEntity, addAssetsDto: AddAssetsDto): Promise<AddAssetsResponseDto>;
updateThumbnails(): Promise<number | undefined>; updateThumbnails(): Promise<number | undefined>;
getCountByUserId(userId: string): Promise<AlbumCountResponseDto>;
getSharedWithUserAlbumCount(userId: string, assetId: string): Promise<number>; getSharedWithUserAlbumCount(userId: string, assetId: string): Promise<number>;
} }
@ -26,14 +24,6 @@ export class AlbumRepository implements IAlbumRepository {
@InjectRepository(AssetEntity) private assetRepository: Repository<AssetEntity>, @InjectRepository(AssetEntity) private assetRepository: Repository<AssetEntity>,
) {} ) {}
async getCountByUserId(userId: string): Promise<AlbumCountResponseDto> {
const ownedAlbums = await this.albumRepository.find({ where: { ownerId: userId }, relations: ['sharedUsers'] });
const sharedAlbums = await this.albumRepository.count({ where: { sharedUsers: { id: userId } } });
const sharedAlbumCount = ownedAlbums.filter((album) => album.sharedUsers?.length > 0).length;
return new AlbumCountResponseDto(ownedAlbums.length, sharedAlbums, sharedAlbumCount);
}
async get(albumId: string): Promise<AlbumEntity | null> { async get(albumId: string): Promise<AlbumEntity | null> {
return this.albumRepository.findOne({ return this.albumRepository.findOne({
where: { id: albumId }, where: { id: albumId },

View File

@ -6,7 +6,6 @@ import { AddAssetsDto } from './dto/add-assets.dto';
import { RemoveAssetsDto } from './dto/remove-assets.dto'; import { RemoveAssetsDto } from './dto/remove-assets.dto';
import { ApiOkResponse, ApiTags } from '@nestjs/swagger'; import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
import { AlbumResponseDto } from '@app/domain'; import { AlbumResponseDto } from '@app/domain';
import { AlbumCountResponseDto } from './response-dto/album-count-response.dto';
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto'; import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto';
import { Response as Res } from 'express'; import { Response as Res } from 'express';
import { DownloadDto } from '../asset/dto/download-library.dto'; import { DownloadDto } from '../asset/dto/download-library.dto';
@ -22,11 +21,6 @@ import { handleDownload } from '../../app.utils';
export class AlbumController { export class AlbumController {
constructor(private readonly service: AlbumService) {} constructor(private readonly service: AlbumService) {}
@Get('count-by-user-id')
getAlbumCountByUserId(@GetAuthUser() authUser: AuthUserDto): Promise<AlbumCountResponseDto> {
return this.service.getCountByUserId(authUser);
}
@SharedLinkRoute() @SharedLinkRoute()
@Put(':id/assets') @Put(':id/assets')
addAssetsToAlbum( addAssetsToAlbum(

View File

@ -98,7 +98,6 @@ describe('Album service', () => {
get: jest.fn(), get: jest.fn(),
removeAssets: jest.fn(), removeAssets: jest.fn(),
updateThumbnails: jest.fn(), updateThumbnails: jest.fn(),
getCountByUserId: jest.fn(),
getSharedWithUserAlbumCount: jest.fn(), getSharedWithUserAlbumCount: jest.fn(),
}; };

View File

@ -4,7 +4,6 @@ import { AlbumEntity, SharedLinkType } from '@app/infra/entities';
import { RemoveAssetsDto } from './dto/remove-assets.dto'; import { RemoveAssetsDto } from './dto/remove-assets.dto';
import { AlbumResponseDto, mapAlbum } from '@app/domain'; import { AlbumResponseDto, mapAlbum } from '@app/domain';
import { IAlbumRepository } from './album-repository'; import { IAlbumRepository } from './album-repository';
import { AlbumCountResponseDto } from './response-dto/album-count-response.dto';
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto'; import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto';
import { AddAssetsDto } from './dto/add-assets.dto'; import { AddAssetsDto } from './dto/add-assets.dto';
import { DownloadService } from '../../modules/download/download.service'; import { DownloadService } from '../../modules/download/download.service';
@ -90,10 +89,6 @@ export class AlbumService {
}; };
} }
async getCountByUserId(authUser: AuthUserDto): Promise<AlbumCountResponseDto> {
return this.albumRepository.getCountByUserId(authUser.id);
}
async downloadArchive(authUser: AuthUserDto, albumId: string, dto: DownloadDto) { async downloadArchive(authUser: AuthUserDto, albumId: string, dto: DownloadDto) {
this.shareCore.checkDownloadAccess(authUser); this.shareCore.checkDownloadAccess(authUser);

View File

@ -1,18 +0,0 @@
import { ApiProperty } from '@nestjs/swagger';
export class AlbumCountResponseDto {
@ApiProperty({ type: 'integer' })
owned!: number;
@ApiProperty({ type: 'integer' })
shared!: number;
@ApiProperty({ type: 'integer' })
sharing!: number;
constructor(owned: number, shared: number, sharing: number) {
this.owned = owned;
this.shared = shared;
this.sharing = sharing;
}
}

View File

@ -1,4 +1,11 @@
import { AddUsersDto, AlbumService, AuthUserDto, CreateAlbumDto, UpdateAlbumDto } from '@app/domain'; import {
AddUsersDto,
AlbumCountResponseDto,
AlbumService,
AuthUserDto,
CreateAlbumDto,
UpdateAlbumDto,
} from '@app/domain';
import { GetAlbumsDto } from '@app/domain/album/dto/get-albums.dto'; import { GetAlbumsDto } from '@app/domain/album/dto/get-albums.dto';
import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common'; import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
@ -15,6 +22,11 @@ import { UUIDParamDto } from './dto/uuid-param.dto';
export class AlbumController { export class AlbumController {
constructor(private service: AlbumService) {} constructor(private service: AlbumService) {}
@Get('count')
getAlbumCount(@GetAuthUser() authUser: AuthUserDto): Promise<AlbumCountResponseDto> {
return this.service.getCount(authUser);
}
@Get() @Get()
getAllAlbums(@GetAuthUser() authUser: AuthUserDto, @Query() query: GetAlbumsDto) { getAllAlbums(@GetAuthUser() authUser: AuthUserDto, @Query() query: GetAlbumsDto) {
return this.service.getAll(authUser, query); return this.service.getAll(authUser, query);

View File

@ -210,7 +210,7 @@ export interface AlbumCountResponseDto {
* @type {number} * @type {number}
* @memberof AlbumCountResponseDto * @memberof AlbumCountResponseDto
*/ */
'sharing': number; 'notShared': number;
} }
/** /**
* *
@ -3678,8 +3678,8 @@ export const AlbumApiAxiosParamCreator = function (configuration?: Configuration
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
getAlbumCountByUserId: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => { getAlbumCount: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/album/count-by-user-id`; const localVarPath = `/album/count`;
// use dummy base URL string because the URL constructor only accepts absolute URLs. // use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions; let baseOptions;
@ -4029,8 +4029,8 @@ export const AlbumApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
async getAlbumCountByUserId(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AlbumCountResponseDto>> { async getAlbumCount(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AlbumCountResponseDto>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getAlbumCountByUserId(options); const localVarAxiosArgs = await localVarAxiosParamCreator.getAlbumCount(options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
}, },
/** /**
@ -4163,8 +4163,8 @@ export const AlbumApiFactory = function (configuration?: Configuration, basePath
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
getAlbumCountByUserId(options?: any): AxiosPromise<AlbumCountResponseDto> { getAlbumCount(options?: any): AxiosPromise<AlbumCountResponseDto> {
return localVarFp.getAlbumCountByUserId(options).then((request) => request(axios, basePath)); return localVarFp.getAlbumCount(options).then((request) => request(axios, basePath));
}, },
/** /**
* *
@ -4529,8 +4529,8 @@ export class AlbumApi extends BaseAPI {
* @throws {RequiredError} * @throws {RequiredError}
* @memberof AlbumApi * @memberof AlbumApi
*/ */
public getAlbumCountByUserId(options?: AxiosRequestConfig) { public getAlbumCount(options?: AxiosRequestConfig) {
return AlbumApiFp(this.configuration).getAlbumCountByUserId(options).then((request) => request(this.axios, this.basePath)); return AlbumApiFp(this.configuration).getAlbumCount(options).then((request) => request(this.axios, this.basePath));
} }
/** /**

View File

@ -47,18 +47,10 @@
const getAlbumCount = async () => { const getAlbumCount = async () => {
try { try {
const { data: albumCount } = await api.albumApi.getAlbumCountByUserId(); const { data: albumCount } = await api.albumApi.getAlbumCount();
return { return albumCount;
shared: albumCount.shared,
sharing: albumCount.sharing,
owned: albumCount.owned
};
} catch { } catch {
return { return { owned: 0, shared: 0, notShared: 0 };
shared: 0,
sharing: 0,
owned: 0
};
} }
}; };
@ -133,7 +125,7 @@
<LoadingSpinner /> <LoadingSpinner />
{:then data} {:then data}
<div> <div>
<p>{(data.shared + data.sharing).toLocaleString($locale)} Albums</p> <p>{data.shared.toLocaleString($locale)} Albums</p>
</div> </div>
{/await} {/await}
</svelte:fragment> </svelte:fragment>