mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
dto refactor
add logging handle metadata
This commit is contained in:
Generated
+82
-9
@@ -137,12 +137,15 @@ class UploadApi {
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] draftUploadInteropVersion (required):
|
||||
/// Indicates the version of the RUFH protocol supported by the client.
|
||||
///
|
||||
/// * [String] id (required):
|
||||
///
|
||||
/// * [String] key:
|
||||
///
|
||||
/// * [String] slug:
|
||||
Future<Response> getUploadStatusWithHttpInfo(String id, { String? key, String? slug, }) async {
|
||||
Future<Response> getUploadStatusWithHttpInfo(String draftUploadInteropVersion, String id, { String? key, String? slug, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final apiPath = r'/upload/{id}'
|
||||
.replaceAll('{id}', id);
|
||||
@@ -161,6 +164,8 @@ class UploadApi {
|
||||
queryParams.addAll(_queryParams('', 'slug', slug));
|
||||
}
|
||||
|
||||
headerParams[r'draft-upload-interop-version'] = parameterToString(draftUploadInteropVersion);
|
||||
|
||||
const contentTypes = <String>[];
|
||||
|
||||
|
||||
@@ -179,13 +184,16 @@ class UploadApi {
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] draftUploadInteropVersion (required):
|
||||
/// Indicates the version of the RUFH protocol supported by the client.
|
||||
///
|
||||
/// * [String] id (required):
|
||||
///
|
||||
/// * [String] key:
|
||||
///
|
||||
/// * [String] slug:
|
||||
Future<void> getUploadStatus(String id, { String? key, String? slug, }) async {
|
||||
final response = await getUploadStatusWithHttpInfo(id, key: key, slug: slug, );
|
||||
Future<void> getUploadStatus(String draftUploadInteropVersion, String id, { String? key, String? slug, }) async {
|
||||
final response = await getUploadStatusWithHttpInfo(draftUploadInteropVersion, id, key: key, slug: slug, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
@@ -197,12 +205,24 @@ class UploadApi {
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] contentLength (required):
|
||||
/// Non-negative size of the request body in bytes.
|
||||
///
|
||||
/// * [String] draftUploadInteropVersion (required):
|
||||
/// Indicates the version of the RUFH protocol supported by the client.
|
||||
///
|
||||
/// * [String] id (required):
|
||||
///
|
||||
/// * [String] uploadComplete (required):
|
||||
/// Structured boolean indicating whether this request completes the file. Use Upload-Incomplete instead for version <= 3.
|
||||
///
|
||||
/// * [String] uploadOffset (required):
|
||||
/// Non-negative byte offset indicating the starting position of the data in the request body within the entire file.
|
||||
///
|
||||
/// * [String] key:
|
||||
///
|
||||
/// * [String] slug:
|
||||
Future<Response> resumeUploadWithHttpInfo(String id, { String? key, String? slug, }) async {
|
||||
Future<Response> resumeUploadWithHttpInfo(String contentLength, String draftUploadInteropVersion, String id, String uploadComplete, String uploadOffset, { String? key, String? slug, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final apiPath = r'/upload/{id}'
|
||||
.replaceAll('{id}', id);
|
||||
@@ -221,6 +241,11 @@ class UploadApi {
|
||||
queryParams.addAll(_queryParams('', 'slug', slug));
|
||||
}
|
||||
|
||||
headerParams[r'content-length'] = parameterToString(contentLength);
|
||||
headerParams[r'draft-upload-interop-version'] = parameterToString(draftUploadInteropVersion);
|
||||
headerParams[r'upload-complete'] = parameterToString(uploadComplete);
|
||||
headerParams[r'upload-offset'] = parameterToString(uploadOffset);
|
||||
|
||||
const contentTypes = <String>[];
|
||||
|
||||
|
||||
@@ -239,13 +264,25 @@ class UploadApi {
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] contentLength (required):
|
||||
/// Non-negative size of the request body in bytes.
|
||||
///
|
||||
/// * [String] draftUploadInteropVersion (required):
|
||||
/// Indicates the version of the RUFH protocol supported by the client.
|
||||
///
|
||||
/// * [String] id (required):
|
||||
///
|
||||
/// * [String] uploadComplete (required):
|
||||
/// Structured boolean indicating whether this request completes the file. Use Upload-Incomplete instead for version <= 3.
|
||||
///
|
||||
/// * [String] uploadOffset (required):
|
||||
/// Non-negative byte offset indicating the starting position of the data in the request body within the entire file.
|
||||
///
|
||||
/// * [String] key:
|
||||
///
|
||||
/// * [String] slug:
|
||||
Future<void> resumeUpload(String id, { String? key, String? slug, }) async {
|
||||
final response = await resumeUploadWithHttpInfo(id, key: key, slug: slug, );
|
||||
Future<void> resumeUpload(String contentLength, String draftUploadInteropVersion, String id, String uploadComplete, String uploadOffset, { String? key, String? slug, }) async {
|
||||
final response = await resumeUploadWithHttpInfo(contentLength, draftUploadInteropVersion, id, uploadComplete, uploadOffset, key: key, slug: slug, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
@@ -257,10 +294,25 @@ class UploadApi {
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] contentLength (required):
|
||||
/// Non-negative size of the request body in bytes.
|
||||
///
|
||||
/// * [String] draftUploadInteropVersion (required):
|
||||
/// Indicates the version of the RUFH protocol supported by the client.
|
||||
///
|
||||
/// * [String] reprDigest (required):
|
||||
/// Structured dictionary containing an SHA-1 checksum used to detect duplicate files and validate data integrity.
|
||||
///
|
||||
/// * [String] uploadComplete (required):
|
||||
/// Structured boolean indicating whether this request completes the file. Use Upload-Incomplete instead for version <= 3.
|
||||
///
|
||||
/// * [String] xImmichAssetData (required):
|
||||
/// Base64-encoded JSON of asset metadata. The expected content is the same as AssetMediaCreateDto, except that `filename` is required and `sidecarData` is ignored.
|
||||
///
|
||||
/// * [String] key:
|
||||
///
|
||||
/// * [String] slug:
|
||||
Future<Response> startUploadWithHttpInfo({ String? key, String? slug, }) async {
|
||||
Future<Response> startUploadWithHttpInfo(String contentLength, String draftUploadInteropVersion, String reprDigest, String uploadComplete, String xImmichAssetData, { String? key, String? slug, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final apiPath = r'/upload';
|
||||
|
||||
@@ -278,6 +330,12 @@ class UploadApi {
|
||||
queryParams.addAll(_queryParams('', 'slug', slug));
|
||||
}
|
||||
|
||||
headerParams[r'content-length'] = parameterToString(contentLength);
|
||||
headerParams[r'draft-upload-interop-version'] = parameterToString(draftUploadInteropVersion);
|
||||
headerParams[r'repr-digest'] = parameterToString(reprDigest);
|
||||
headerParams[r'upload-complete'] = parameterToString(uploadComplete);
|
||||
headerParams[r'x-immich-asset-data'] = parameterToString(xImmichAssetData);
|
||||
|
||||
const contentTypes = <String>[];
|
||||
|
||||
|
||||
@@ -296,11 +354,26 @@ class UploadApi {
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] contentLength (required):
|
||||
/// Non-negative size of the request body in bytes.
|
||||
///
|
||||
/// * [String] draftUploadInteropVersion (required):
|
||||
/// Indicates the version of the RUFH protocol supported by the client.
|
||||
///
|
||||
/// * [String] reprDigest (required):
|
||||
/// Structured dictionary containing an SHA-1 checksum used to detect duplicate files and validate data integrity.
|
||||
///
|
||||
/// * [String] uploadComplete (required):
|
||||
/// Structured boolean indicating whether this request completes the file. Use Upload-Incomplete instead for version <= 3.
|
||||
///
|
||||
/// * [String] xImmichAssetData (required):
|
||||
/// Base64-encoded JSON of asset metadata. The expected content is the same as AssetMediaCreateDto, except that `filename` is required and `sidecarData` is ignored.
|
||||
///
|
||||
/// * [String] key:
|
||||
///
|
||||
/// * [String] slug:
|
||||
Future<void> startUpload({ String? key, String? slug, }) async {
|
||||
final response = await startUploadWithHttpInfo( key: key, slug: slug, );
|
||||
Future<void> startUpload(String contentLength, String draftUploadInteropVersion, String reprDigest, String uploadComplete, String xImmichAssetData, { String? key, String? slug, }) async {
|
||||
final response = await startUploadWithHttpInfo(contentLength, draftUploadInteropVersion, reprDigest, uploadComplete, xImmichAssetData, key: key, slug: slug, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
enum BackupSelection {
|
||||
// Used to sort albums based on the backupSelection
|
||||
// selected -> none -> excluded
|
||||
// Do not change the order of these values
|
||||
selected,
|
||||
none,
|
||||
excluded,
|
||||
}
|
||||
|
||||
class LocalAlbum {
|
||||
final String id;
|
||||
final String name;
|
||||
final DateTime updatedAt;
|
||||
final bool isIosSharedAlbum;
|
||||
|
||||
final int assetCount;
|
||||
final BackupSelection backupSelection;
|
||||
final String? linkedRemoteAlbumId;
|
||||
|
||||
const LocalAlbum({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.updatedAt,
|
||||
this.assetCount = 0,
|
||||
this.backupSelection = BackupSelection.none,
|
||||
this.isIosSharedAlbum = false,
|
||||
this.linkedRemoteAlbumId,
|
||||
});
|
||||
|
||||
LocalAlbum copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
DateTime? updatedAt,
|
||||
int? assetCount,
|
||||
BackupSelection? backupSelection,
|
||||
bool? isIosSharedAlbum,
|
||||
String? linkedRemoteAlbumId,
|
||||
}) {
|
||||
return LocalAlbum(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
assetCount: assetCount ?? this.assetCount,
|
||||
backupSelection: backupSelection ?? this.backupSelection,
|
||||
isIosSharedAlbum: isIosSharedAlbum ?? this.isIosSharedAlbum,
|
||||
linkedRemoteAlbumId: linkedRemoteAlbumId ?? this.linkedRemoteAlbumId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (other is! LocalAlbum) return false;
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other.id == id &&
|
||||
other.name == name &&
|
||||
other.updatedAt == updatedAt &&
|
||||
other.assetCount == assetCount &&
|
||||
other.backupSelection == backupSelection &&
|
||||
other.isIosSharedAlbum == isIosSharedAlbum &&
|
||||
other.linkedRemoteAlbumId == linkedRemoteAlbumId;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return id.hashCode ^
|
||||
name.hashCode ^
|
||||
updatedAt.hashCode ^
|
||||
assetCount.hashCode ^
|
||||
backupSelection.hashCode ^
|
||||
isIosSharedAlbum.hashCode ^
|
||||
linkedRemoteAlbumId.hashCode;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''LocalAlbum: {
|
||||
id: $id,
|
||||
name: $name,
|
||||
updatedAt: $updatedAt,
|
||||
assetCount: $assetCount,
|
||||
backupSelection: $backupSelection,
|
||||
isIosSharedAlbum: $isIosSharedAlbum
|
||||
linkedRemoteAlbumId: $linkedRemoteAlbumId,
|
||||
}''';
|
||||
}
|
||||
}
|
||||
|
||||
int square(int num) {
|
||||
return num * num;
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
List<LocalAlbum> getAlbums() {
|
||||
final updatedAt = DateTime.now();
|
||||
final selection = BackupSelection.values;
|
||||
return List.generate(100000, (i) {
|
||||
return LocalAlbum(id: i.toString(), name: '', updatedAt: updatedAt, backupSelection: selection[i % 3]);
|
||||
});
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
List<LocalAlbum> setAlbum1(List<LocalAlbum> albums, LocalAlbum album) {
|
||||
final newAlbums = List.filled(albums.length, LocalAlbum(id: '', name: '', updatedAt: DateTime.now()));
|
||||
newAlbums.setAll(0, albums);
|
||||
for (int i = 0; i < newAlbums.length; i++) {
|
||||
final currentAlbum = newAlbums[i];
|
||||
if (currentAlbum.id == album.id) {
|
||||
newAlbums[i] = currentAlbum.copyWith(backupSelection: BackupSelection.selected);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return newAlbums;
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
List<LocalAlbum> setAlbum2(List<LocalAlbum> albums, LocalAlbum album) {
|
||||
final newAlbums = List.filled(albums.length, LocalAlbum(id: '', name: '', updatedAt: DateTime.now()));
|
||||
for (int i = 0; i < newAlbums.length; i++) {
|
||||
final currentAlbum = newAlbums[i];
|
||||
newAlbums[i] = currentAlbum.id == album.id ? currentAlbum.copyWith(backupSelection: BackupSelection.selected) : currentAlbum;
|
||||
}
|
||||
return newAlbums;
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
List<LocalAlbum> setAlbum3(List<LocalAlbum> albums, LocalAlbum album) {
|
||||
final newAlbums = albums.toList(growable: false);
|
||||
for (int i = 0; i < newAlbums.length; i++) {
|
||||
final currentAlbum = newAlbums[i];
|
||||
if (currentAlbum.id == album.id) {
|
||||
newAlbums[i] = currentAlbum.copyWith(backupSelection: BackupSelection.selected);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return newAlbums;
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
Set<String> toSet1(List<LocalAlbum> albums) {
|
||||
return albums.map((album) => album.id).toSet();
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
Set<String> toSet2(List<LocalAlbum> albums) {
|
||||
final ids = <String>{};
|
||||
for (final album in albums) {
|
||||
ids.add(album.id);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
Set<String> toSet3(List<LocalAlbum> albums) {
|
||||
return Set.unmodifiable(albums.map((album) => album.id));
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
Set<String> toSet4(List<LocalAlbum> albums) {
|
||||
final ids = <String>{};
|
||||
for (int i = 0; i < albums.length; i++) {
|
||||
final id = albums[i].id;
|
||||
ids.add(id);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
List<LocalAlbum> toFiltered1(List<LocalAlbum> albums, BackupSelection selection) {
|
||||
return albums.where((album) => album.backupSelection == selection).toList(growable: false);
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
List<LocalAlbum> toFiltered2(List<LocalAlbum> albums, BackupSelection selection) {
|
||||
final filtered = <LocalAlbum>[];
|
||||
for (final album in albums) {
|
||||
if (album.backupSelection == selection) {
|
||||
filtered.add(album);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
@pragma('vm:never-inline')
|
||||
List<LocalAlbum> toFiltered3(List<LocalAlbum> albums, BackupSelection selection) {
|
||||
final filtered = <LocalAlbum>[];
|
||||
for (int i = 0; i < albums.length; i++) {
|
||||
final album = albums[i];
|
||||
if (album.backupSelection == selection) {
|
||||
filtered.add(album);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
late Set<String> ids;
|
||||
late List<LocalAlbum> localAlbums;
|
||||
void main(List<String> args) {
|
||||
final albums = getAlbums();
|
||||
// final album = LocalAlbum(id: '50000', name: '', updatedAt: DateTime.now());
|
||||
final stopwatch = Stopwatch()..start();
|
||||
// localAlbums = setAlbum3(albums, album);
|
||||
// ids = toSet1(albums);
|
||||
localAlbums = toFiltered2(albums, BackupSelection.selected);
|
||||
stopwatch.stop();
|
||||
print('Elapsed time: ${(stopwatch.elapsedMicroseconds / 1000).toStringAsFixed(2)}ms');
|
||||
}
|
||||
Reference in New Issue
Block a user