From 23a6f58a8a9959d17ad726ce7eab684ca3a5a1ea Mon Sep 17 00:00:00 2001 From: Dell Date: Sat, 30 May 2026 17:49:02 -0400 Subject: [PATCH] Improving the code. --- mobile/openapi/README.md | 1 - mobile/openapi/lib/api.dart | 1 - mobile/openapi/lib/api_client.dart | 2 - .../model/user_upload_stats_response_dto.dart | 22 ++-- ...ser_upload_stats_response_dto_summary.dart | 103 ------------------ open-api/immich-openapi-specs.json | 22 ++-- packages/sdk/src/fetch-client.ts | 6 +- server/src/dtos/user.dto.ts | 4 +- server/src/services/user.service.ts | 2 +- .../user-settings/UserUsageStatistic.svelte | 8 +- 10 files changed, 27 insertions(+), 144 deletions(-) delete mode 100644 mobile/openapi/lib/model/user_upload_stats_response_dto_summary.dart diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index ea56c388a3..f9ec2e60e9 100644 --- a/mobile/openapi/README.md +++ b/mobile/openapi/README.md @@ -659,7 +659,6 @@ Class | Method | HTTP request | Description - [UserUpdateMeDto](doc//UserUpdateMeDto.md) - [UserUploadStatsResponseDto](doc//UserUploadStatsResponseDto.md) - [UserUploadStatsResponseDtoSeriesInner](doc//UserUploadStatsResponseDtoSeriesInner.md) - - [UserUploadStatsResponseDtoSummary](doc//UserUploadStatsResponseDtoSummary.md) - [ValidateAccessTokenResponseDto](doc//ValidateAccessTokenResponseDto.md) - [ValidateLibraryDto](doc//ValidateLibraryDto.md) - [ValidateLibraryImportPathResponseDto](doc//ValidateLibraryImportPathResponseDto.md) diff --git a/mobile/openapi/lib/api.dart b/mobile/openapi/lib/api.dart index b8c845c178..e33e780717 100644 --- a/mobile/openapi/lib/api.dart +++ b/mobile/openapi/lib/api.dart @@ -404,7 +404,6 @@ part 'model/user_status.dart'; part 'model/user_update_me_dto.dart'; part 'model/user_upload_stats_response_dto.dart'; part 'model/user_upload_stats_response_dto_series_inner.dart'; -part 'model/user_upload_stats_response_dto_summary.dart'; part 'model/validate_access_token_response_dto.dart'; part 'model/validate_library_dto.dart'; part 'model/validate_library_import_path_response_dto.dart'; diff --git a/mobile/openapi/lib/api_client.dart b/mobile/openapi/lib/api_client.dart index 3de62e23ea..bc588f0132 100644 --- a/mobile/openapi/lib/api_client.dart +++ b/mobile/openapi/lib/api_client.dart @@ -854,8 +854,6 @@ class ApiClient { return UserUploadStatsResponseDto.fromJson(value); case 'UserUploadStatsResponseDtoSeriesInner': return UserUploadStatsResponseDtoSeriesInner.fromJson(value); - case 'UserUploadStatsResponseDtoSummary': - return UserUploadStatsResponseDtoSummary.fromJson(value); case 'ValidateAccessTokenResponseDto': return ValidateAccessTokenResponseDto.fromJson(value); case 'ValidateLibraryDto': diff --git a/mobile/openapi/lib/model/user_upload_stats_response_dto.dart b/mobile/openapi/lib/model/user_upload_stats_response_dto.dart index 2ae1b23e40..e09e2436ab 100644 --- a/mobile/openapi/lib/model/user_upload_stats_response_dto.dart +++ b/mobile/openapi/lib/model/user_upload_stats_response_dto.dart @@ -15,8 +15,8 @@ class UserUploadStatsResponseDto { UserUploadStatsResponseDto({ required this.from, this.series = const [], - required this.summary, required this.to, + required this.totalCount, required this.userId, }); @@ -25,11 +25,15 @@ class UserUploadStatsResponseDto { List series; - UserUploadStatsResponseDtoSummary summary; - /// End date in UTC String to; + /// Total number of uploads + /// + /// Minimum value: -9007199254740991 + /// Maximum value: 9007199254740991 + int totalCount; + /// User ID String userId; @@ -37,8 +41,8 @@ class UserUploadStatsResponseDto { bool operator ==(Object other) => identical(this, other) || other is UserUploadStatsResponseDto && other.from == from && _deepEquality.equals(other.series, series) && - other.summary == summary && other.to == to && + other.totalCount == totalCount && other.userId == userId; @override @@ -46,19 +50,19 @@ class UserUploadStatsResponseDto { // ignore: unnecessary_parenthesis (from.hashCode) + (series.hashCode) + - (summary.hashCode) + (to.hashCode) + + (totalCount.hashCode) + (userId.hashCode); @override - String toString() => 'UserUploadStatsResponseDto[from=$from, series=$series, summary=$summary, to=$to, userId=$userId]'; + String toString() => 'UserUploadStatsResponseDto[from=$from, series=$series, to=$to, totalCount=$totalCount, userId=$userId]'; Map toJson() { final json = {}; json[r'from'] = this.from; json[r'series'] = this.series; - json[r'summary'] = this.summary; json[r'to'] = this.to; + json[r'totalCount'] = this.totalCount; json[r'userId'] = this.userId; return json; } @@ -74,8 +78,8 @@ class UserUploadStatsResponseDto { return UserUploadStatsResponseDto( from: mapValueOfType(json, r'from')!, series: UserUploadStatsResponseDtoSeriesInner.listFromJson(json[r'series']), - summary: UserUploadStatsResponseDtoSummary.fromJson(json[r'summary'])!, to: mapValueOfType(json, r'to')!, + totalCount: mapValueOfType(json, r'totalCount')!, userId: mapValueOfType(json, r'userId')!, ); } @@ -126,8 +130,8 @@ class UserUploadStatsResponseDto { static const requiredKeys = { 'from', 'series', - 'summary', 'to', + 'totalCount', 'userId', }; } diff --git a/mobile/openapi/lib/model/user_upload_stats_response_dto_summary.dart b/mobile/openapi/lib/model/user_upload_stats_response_dto_summary.dart deleted file mode 100644 index 11abb45a0c..0000000000 --- a/mobile/openapi/lib/model/user_upload_stats_response_dto_summary.dart +++ /dev/null @@ -1,103 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.18 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -part of openapi.api; - -class UserUploadStatsResponseDtoSummary { - /// Returns a new [UserUploadStatsResponseDtoSummary] instance. - UserUploadStatsResponseDtoSummary({ - required this.totalCount, - }); - - /// Total number of uploads - /// - /// Minimum value: -9007199254740991 - /// Maximum value: 9007199254740991 - int totalCount; - - @override - bool operator ==(Object other) => identical(this, other) || other is UserUploadStatsResponseDtoSummary && - other.totalCount == totalCount; - - @override - int get hashCode => - // ignore: unnecessary_parenthesis - (totalCount.hashCode); - - @override - String toString() => 'UserUploadStatsResponseDtoSummary[totalCount=$totalCount]'; - - Map toJson() { - final json = {}; - json[r'totalCount'] = this.totalCount; - return json; - } - - /// Returns a new [UserUploadStatsResponseDtoSummary] instance and imports its values from - /// [value] if it's a [Map], null otherwise. - // ignore: prefer_constructors_over_static_methods - static UserUploadStatsResponseDtoSummary? fromJson(dynamic value) { - upgradeDto(value, "UserUploadStatsResponseDtoSummary"); - if (value is Map) { - final json = value.cast(); - - return UserUploadStatsResponseDtoSummary( - totalCount: mapValueOfType(json, r'totalCount')!, - ); - } - return null; - } - - static List listFromJson(dynamic json, {bool growable = false,}) { - final result = []; - if (json is List && json.isNotEmpty) { - for (final row in json) { - final value = UserUploadStatsResponseDtoSummary.fromJson(row); - if (value != null) { - result.add(value); - } - } - } - return result.toList(growable: growable); - } - - static Map mapFromJson(dynamic json) { - final map = {}; - if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments - for (final entry in json.entries) { - final value = UserUploadStatsResponseDtoSummary.fromJson(entry.value); - if (value != null) { - map[entry.key] = value; - } - } - } - return map; - } - - // maps a json object with a list of UserUploadStatsResponseDtoSummary-objects as value to a dart map - static Map> mapListFromJson(dynamic json, {bool growable = false,}) { - final map = >{}; - if (json is Map && json.isNotEmpty) { - // ignore: parameter_assignments - json = json.cast(); - for (final entry in json.entries) { - map[entry.key] = UserUploadStatsResponseDtoSummary.listFromJson(entry.value, growable: growable,); - } - } - return map; - } - - /// The list of required keys that must be present in a JSON. - static const requiredKeys = { - 'totalCount', - }; -} - diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 4e8b366890..cbf27c5b3c 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -26050,25 +26050,17 @@ }, "type": "array" }, - "summary": { - "properties": { - "totalCount": { - "description": "Total number of uploads", - "maximum": 9007199254740991, - "minimum": -9007199254740991, - "type": "integer" - } - }, - "required": [ - "totalCount" - ], - "type": "object" - }, "to": { "description": "End date in UTC", "example": "2024-12-31", "type": "string" }, + "totalCount": { + "description": "Total number of uploads", + "maximum": 9007199254740991, + "minimum": -9007199254740991, + "type": "integer" + }, "userId": { "description": "User ID", "format": "uuid", @@ -26079,8 +26071,8 @@ "required": [ "from", "series", - "summary", "to", + "totalCount", "userId" ], "type": "object" diff --git a/packages/sdk/src/fetch-client.ts b/packages/sdk/src/fetch-client.ts index 44e368f3f6..1ede8980f4 100644 --- a/packages/sdk/src/fetch-client.ts +++ b/packages/sdk/src/fetch-client.ts @@ -2664,12 +2664,10 @@ export type UserUploadStatsResponseDto = { /** Date in UTC */ date: string; }[]; - summary: { - /** Total number of uploads */ - totalCount: number; - }; /** End date in UTC */ to: string; + /** Total number of uploads */ + totalCount: number; /** User ID */ userId: string; }; diff --git a/server/src/dtos/user.dto.ts b/server/src/dtos/user.dto.ts index 3dfecf3f48..cf8995f24e 100644 --- a/server/src/dtos/user.dto.ts +++ b/server/src/dtos/user.dto.ts @@ -50,9 +50,7 @@ const UserUploadStatsResponseSchema = z count: z.int().describe('Number of uploads'), }), ), - summary: z.object({ - totalCount: z.int().describe('Total number of uploads'), - }), + totalCount: z.int().describe('Total number of uploads'), }) .meta({ id: 'UserUploadStatsResponseDto' }); diff --git a/server/src/services/user.service.ts b/server/src/services/user.service.ts index f08b6dca20..353174b73f 100644 --- a/server/src/services/user.service.ts +++ b/server/src/services/user.service.ts @@ -76,7 +76,7 @@ export class UserService extends BaseService { from: fromDate.toISODate()!, to: toDate.toISODate()!, series, - summary: { totalCount: series.reduce((totalCount, item) => totalCount + item.count, 0) }, + totalCount: series.reduce((totalCount, item) => totalCount + item.count, 0), }; } diff --git a/web/src/routes/(user)/user-settings/UserUsageStatistic.svelte b/web/src/routes/(user)/user-settings/UserUsageStatistic.svelte index 5abbd84fdf..5027ac0e7c 100644 --- a/web/src/routes/(user)/user-settings/UserUsageStatistic.svelte +++ b/web/src/routes/(user)/user-settings/UserUsageStatistic.svelte @@ -17,7 +17,7 @@ from: string; to: string; series: Array<{ date: string; count: number }>; - summary: { totalCount: number }; + totalCount: number; }; let timelineStats: AssetStatsResponseDto = $state({ @@ -55,7 +55,7 @@ from: '', to: '', series: [], - summary: { totalCount: 0 }, + totalCount: 0, }); const today = DateTime.utc().startOf('day'); @@ -201,9 +201,7 @@ {$t('more')} - {$t('upload_activity_total_count', { values: { count: uploadStats.summary.totalCount } })} + {$t('upload_activity_total_count', { values: { count: uploadStats.totalCount } })}