Improving the code.

pull/28593/head
Dell 2026-05-30 17:49:02 -04:00
parent 326e574bf0
commit 23a6f58a8a
10 changed files with 27 additions and 144 deletions

View File

@ -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)

View File

@ -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';

View File

@ -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':

View File

@ -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<UserUploadStatsResponseDtoSeriesInner> 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<String, dynamic> toJson() {
final json = <String, dynamic>{};
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<String>(json, r'from')!,
series: UserUploadStatsResponseDtoSeriesInner.listFromJson(json[r'series']),
summary: UserUploadStatsResponseDtoSummary.fromJson(json[r'summary'])!,
to: mapValueOfType<String>(json, r'to')!,
totalCount: mapValueOfType<int>(json, r'totalCount')!,
userId: mapValueOfType<String>(json, r'userId')!,
);
}
@ -126,8 +130,8 @@ class UserUploadStatsResponseDto {
static const requiredKeys = <String>{
'from',
'series',
'summary',
'to',
'totalCount',
'userId',
};
}

View File

@ -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<String, dynamic> toJson() {
final json = <String, dynamic>{};
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<String, dynamic>();
return UserUploadStatsResponseDtoSummary(
totalCount: mapValueOfType<int>(json, r'totalCount')!,
);
}
return null;
}
static List<UserUploadStatsResponseDtoSummary> listFromJson(dynamic json, {bool growable = false,}) {
final result = <UserUploadStatsResponseDtoSummary>[];
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<String, UserUploadStatsResponseDtoSummary> mapFromJson(dynamic json) {
final map = <String, UserUploadStatsResponseDtoSummary>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // 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<String, List<UserUploadStatsResponseDtoSummary>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<UserUploadStatsResponseDtoSummary>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
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 = <String>{
'totalCount',
};
}

View File

@ -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"

View File

@ -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;
};

View File

@ -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' });

View File

@ -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),
};
}

View File

@ -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 @@
<span class="size-3 rounded-sm bg-immich-primary/70"></span>
<span class="size-3 rounded-sm bg-immich-primary"></span>
<span>{$t('more')}</span>
<span class="ml-4"
>{$t('upload_activity_total_count', { values: { count: uploadStats.summary.totalCount } })}</span
>
<span class="ml-4">{$t('upload_activity_total_count', { values: { count: uploadStats.totalCount } })}</span>
</div>
</div>
</div>