1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-09 23:17:29 +02:00

fix(server): album statistics endpoint (#11924)

This commit is contained in:
Jason Rasmussen
2024-08-20 07:50:36 -04:00
committed by GitHub
parent cde0458dc8
commit ef9a06be5c
14 changed files with 111 additions and 111 deletions

View File

@@ -73,8 +73,8 @@ part 'model/activity_response_dto.dart';
part 'model/activity_statistics_response_dto.dart';
part 'model/add_users_dto.dart';
part 'model/admin_onboarding_update_dto.dart';
part 'model/album_count_response_dto.dart';
part 'model/album_response_dto.dart';
part 'model/album_statistics_response_dto.dart';
part 'model/album_user_add_dto.dart';
part 'model/album_user_create_dto.dart';
part 'model/album_user_response_dto.dart';

View File

@@ -218,47 +218,6 @@ class AlbumsApi {
}
}
/// Performs an HTTP 'GET /albums/count' operation and returns the [Response].
Future<Response> getAlbumCountWithHttpInfo() async {
// ignore: prefer_const_declarations
final path = r'/albums/count';
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
Future<AlbumCountResponseDto?> getAlbumCount() async {
final response = await getAlbumCountWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'AlbumCountResponseDto',) as AlbumCountResponseDto;
}
return null;
}
/// Performs an HTTP 'GET /albums/{id}' operation and returns the [Response].
/// Parameters:
///
@@ -322,6 +281,47 @@ class AlbumsApi {
return null;
}
/// Performs an HTTP 'GET /albums/statistics' operation and returns the [Response].
Future<Response> getAlbumStatisticsWithHttpInfo() async {
// ignore: prefer_const_declarations
final path = r'/albums/statistics';
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
Future<AlbumStatisticsResponseDto?> getAlbumStatistics() async {
final response = await getAlbumStatisticsWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'AlbumStatisticsResponseDto',) as AlbumStatisticsResponseDto;
}
return null;
}
/// Performs an HTTP 'GET /albums' operation and returns the [Response].
/// Parameters:
///

View File

@@ -201,10 +201,10 @@ class ApiClient {
return AddUsersDto.fromJson(value);
case 'AdminOnboardingUpdateDto':
return AdminOnboardingUpdateDto.fromJson(value);
case 'AlbumCountResponseDto':
return AlbumCountResponseDto.fromJson(value);
case 'AlbumResponseDto':
return AlbumResponseDto.fromJson(value);
case 'AlbumStatisticsResponseDto':
return AlbumStatisticsResponseDto.fromJson(value);
case 'AlbumUserAddDto':
return AlbumUserAddDto.fromJson(value);
case 'AlbumUserCreateDto':

View File

@@ -10,9 +10,9 @@
part of openapi.api;
class AlbumCountResponseDto {
/// Returns a new [AlbumCountResponseDto] instance.
AlbumCountResponseDto({
class AlbumStatisticsResponseDto {
/// Returns a new [AlbumStatisticsResponseDto] instance.
AlbumStatisticsResponseDto({
required this.notShared,
required this.owned,
required this.shared,
@@ -25,7 +25,7 @@ class AlbumCountResponseDto {
int shared;
@override
bool operator ==(Object other) => identical(this, other) || other is AlbumCountResponseDto &&
bool operator ==(Object other) => identical(this, other) || other is AlbumStatisticsResponseDto &&
other.notShared == notShared &&
other.owned == owned &&
other.shared == shared;
@@ -38,7 +38,7 @@ class AlbumCountResponseDto {
(shared.hashCode);
@override
String toString() => 'AlbumCountResponseDto[notShared=$notShared, owned=$owned, shared=$shared]';
String toString() => 'AlbumStatisticsResponseDto[notShared=$notShared, owned=$owned, shared=$shared]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -48,14 +48,14 @@ class AlbumCountResponseDto {
return json;
}
/// Returns a new [AlbumCountResponseDto] instance and imports its values from
/// Returns a new [AlbumStatisticsResponseDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static AlbumCountResponseDto? fromJson(dynamic value) {
static AlbumStatisticsResponseDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return AlbumCountResponseDto(
return AlbumStatisticsResponseDto(
notShared: mapValueOfType<int>(json, r'notShared')!,
owned: mapValueOfType<int>(json, r'owned')!,
shared: mapValueOfType<int>(json, r'shared')!,
@@ -64,11 +64,11 @@ class AlbumCountResponseDto {
return null;
}
static List<AlbumCountResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <AlbumCountResponseDto>[];
static List<AlbumStatisticsResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <AlbumStatisticsResponseDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = AlbumCountResponseDto.fromJson(row);
final value = AlbumStatisticsResponseDto.fromJson(row);
if (value != null) {
result.add(value);
}
@@ -77,12 +77,12 @@ class AlbumCountResponseDto {
return result.toList(growable: growable);
}
static Map<String, AlbumCountResponseDto> mapFromJson(dynamic json) {
final map = <String, AlbumCountResponseDto>{};
static Map<String, AlbumStatisticsResponseDto> mapFromJson(dynamic json) {
final map = <String, AlbumStatisticsResponseDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = AlbumCountResponseDto.fromJson(entry.value);
final value = AlbumStatisticsResponseDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
@@ -91,14 +91,14 @@ class AlbumCountResponseDto {
return map;
}
// maps a json object with a list of AlbumCountResponseDto-objects as value to a dart map
static Map<String, List<AlbumCountResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<AlbumCountResponseDto>>{};
// maps a json object with a list of AlbumStatisticsResponseDto-objects as value to a dart map
static Map<String, List<AlbumStatisticsResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<AlbumStatisticsResponseDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = AlbumCountResponseDto.listFromJson(entry.value, growable: growable,);
map[entry.key] = AlbumStatisticsResponseDto.listFromJson(entry.value, growable: growable,);
}
}
return map;