mirror of
https://github.com/immich-app/immich.git
synced 2025-06-23 07:20:50 -04:00
feat(server): add duration to SyncAssetV1 (#19196)
add duration to SyncAssetV1 Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
864fe3d0d6
commit
db68d1af9b
@ -169,7 +169,8 @@ class DriftSyncStreamRepository extends DriftDatabaseRepository
|
|||||||
type: Value(asset.type.toAssetType()),
|
type: Value(asset.type.toAssetType()),
|
||||||
createdAt: Value.absentIfNull(asset.fileCreatedAt),
|
createdAt: Value.absentIfNull(asset.fileCreatedAt),
|
||||||
updatedAt: Value.absentIfNull(asset.fileModifiedAt),
|
updatedAt: Value.absentIfNull(asset.fileModifiedAt),
|
||||||
durationInSeconds: const Value(0),
|
durationInSeconds:
|
||||||
|
Value(asset.duration?.toDuration()?.inSeconds ?? 0),
|
||||||
checksum: Value(asset.checksum),
|
checksum: Value(asset.checksum),
|
||||||
isFavorite: Value(asset.isFavorite),
|
isFavorite: Value(asset.isFavorite),
|
||||||
ownerId: Value(asset.ownerId),
|
ownerId: Value(asset.ownerId),
|
||||||
@ -251,3 +252,17 @@ extension on api.AssetVisibility {
|
|||||||
_ => throw Exception('Unknown AssetVisibility value: $this'),
|
_ => throw Exception('Unknown AssetVisibility value: $this'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension on String {
|
||||||
|
Duration? toDuration() {
|
||||||
|
try {
|
||||||
|
final parts = split(':')
|
||||||
|
.map((e) => double.parse(e).toInt())
|
||||||
|
.toList(growable: false);
|
||||||
|
|
||||||
|
return Duration(hours: parts[0], minutes: parts[1], seconds: parts[2]);
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
14
mobile/openapi/lib/model/sync_asset_v1.dart
generated
14
mobile/openapi/lib/model/sync_asset_v1.dart
generated
@ -15,6 +15,7 @@ class SyncAssetV1 {
|
|||||||
SyncAssetV1({
|
SyncAssetV1({
|
||||||
required this.checksum,
|
required this.checksum,
|
||||||
required this.deletedAt,
|
required this.deletedAt,
|
||||||
|
required this.duration,
|
||||||
required this.fileCreatedAt,
|
required this.fileCreatedAt,
|
||||||
required this.fileModifiedAt,
|
required this.fileModifiedAt,
|
||||||
required this.id,
|
required this.id,
|
||||||
@ -31,6 +32,8 @@ class SyncAssetV1 {
|
|||||||
|
|
||||||
DateTime? deletedAt;
|
DateTime? deletedAt;
|
||||||
|
|
||||||
|
String? duration;
|
||||||
|
|
||||||
DateTime? fileCreatedAt;
|
DateTime? fileCreatedAt;
|
||||||
|
|
||||||
DateTime? fileModifiedAt;
|
DateTime? fileModifiedAt;
|
||||||
@ -55,6 +58,7 @@ class SyncAssetV1 {
|
|||||||
bool operator ==(Object other) => identical(this, other) || other is SyncAssetV1 &&
|
bool operator ==(Object other) => identical(this, other) || other is SyncAssetV1 &&
|
||||||
other.checksum == checksum &&
|
other.checksum == checksum &&
|
||||||
other.deletedAt == deletedAt &&
|
other.deletedAt == deletedAt &&
|
||||||
|
other.duration == duration &&
|
||||||
other.fileCreatedAt == fileCreatedAt &&
|
other.fileCreatedAt == fileCreatedAt &&
|
||||||
other.fileModifiedAt == fileModifiedAt &&
|
other.fileModifiedAt == fileModifiedAt &&
|
||||||
other.id == id &&
|
other.id == id &&
|
||||||
@ -71,6 +75,7 @@ class SyncAssetV1 {
|
|||||||
// ignore: unnecessary_parenthesis
|
// ignore: unnecessary_parenthesis
|
||||||
(checksum.hashCode) +
|
(checksum.hashCode) +
|
||||||
(deletedAt == null ? 0 : deletedAt!.hashCode) +
|
(deletedAt == null ? 0 : deletedAt!.hashCode) +
|
||||||
|
(duration == null ? 0 : duration!.hashCode) +
|
||||||
(fileCreatedAt == null ? 0 : fileCreatedAt!.hashCode) +
|
(fileCreatedAt == null ? 0 : fileCreatedAt!.hashCode) +
|
||||||
(fileModifiedAt == null ? 0 : fileModifiedAt!.hashCode) +
|
(fileModifiedAt == null ? 0 : fileModifiedAt!.hashCode) +
|
||||||
(id.hashCode) +
|
(id.hashCode) +
|
||||||
@ -83,7 +88,7 @@ class SyncAssetV1 {
|
|||||||
(visibility.hashCode);
|
(visibility.hashCode);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'SyncAssetV1[checksum=$checksum, deletedAt=$deletedAt, fileCreatedAt=$fileCreatedAt, fileModifiedAt=$fileModifiedAt, id=$id, isFavorite=$isFavorite, localDateTime=$localDateTime, originalFileName=$originalFileName, ownerId=$ownerId, thumbhash=$thumbhash, type=$type, visibility=$visibility]';
|
String toString() => 'SyncAssetV1[checksum=$checksum, deletedAt=$deletedAt, duration=$duration, fileCreatedAt=$fileCreatedAt, fileModifiedAt=$fileModifiedAt, id=$id, isFavorite=$isFavorite, localDateTime=$localDateTime, originalFileName=$originalFileName, ownerId=$ownerId, thumbhash=$thumbhash, type=$type, visibility=$visibility]';
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final json = <String, dynamic>{};
|
final json = <String, dynamic>{};
|
||||||
@ -93,6 +98,11 @@ class SyncAssetV1 {
|
|||||||
} else {
|
} else {
|
||||||
// json[r'deletedAt'] = null;
|
// json[r'deletedAt'] = null;
|
||||||
}
|
}
|
||||||
|
if (this.duration != null) {
|
||||||
|
json[r'duration'] = this.duration;
|
||||||
|
} else {
|
||||||
|
// json[r'duration'] = null;
|
||||||
|
}
|
||||||
if (this.fileCreatedAt != null) {
|
if (this.fileCreatedAt != null) {
|
||||||
json[r'fileCreatedAt'] = this.fileCreatedAt!.toUtc().toIso8601String();
|
json[r'fileCreatedAt'] = this.fileCreatedAt!.toUtc().toIso8601String();
|
||||||
} else {
|
} else {
|
||||||
@ -133,6 +143,7 @@ class SyncAssetV1 {
|
|||||||
return SyncAssetV1(
|
return SyncAssetV1(
|
||||||
checksum: mapValueOfType<String>(json, r'checksum')!,
|
checksum: mapValueOfType<String>(json, r'checksum')!,
|
||||||
deletedAt: mapDateTime(json, r'deletedAt', r''),
|
deletedAt: mapDateTime(json, r'deletedAt', r''),
|
||||||
|
duration: mapValueOfType<String>(json, r'duration'),
|
||||||
fileCreatedAt: mapDateTime(json, r'fileCreatedAt', r''),
|
fileCreatedAt: mapDateTime(json, r'fileCreatedAt', r''),
|
||||||
fileModifiedAt: mapDateTime(json, r'fileModifiedAt', r''),
|
fileModifiedAt: mapDateTime(json, r'fileModifiedAt', r''),
|
||||||
id: mapValueOfType<String>(json, r'id')!,
|
id: mapValueOfType<String>(json, r'id')!,
|
||||||
@ -192,6 +203,7 @@ class SyncAssetV1 {
|
|||||||
static const requiredKeys = <String>{
|
static const requiredKeys = <String>{
|
||||||
'checksum',
|
'checksum',
|
||||||
'deletedAt',
|
'deletedAt',
|
||||||
|
'duration',
|
||||||
'fileCreatedAt',
|
'fileCreatedAt',
|
||||||
'fileModifiedAt',
|
'fileModifiedAt',
|
||||||
'id',
|
'id',
|
||||||
|
@ -13622,6 +13622,10 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"duration": {
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"fileCreatedAt": {
|
"fileCreatedAt": {
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
"nullable": true,
|
"nullable": true,
|
||||||
@ -13671,6 +13675,7 @@
|
|||||||
"required": [
|
"required": [
|
||||||
"checksum",
|
"checksum",
|
||||||
"deletedAt",
|
"deletedAt",
|
||||||
|
"duration",
|
||||||
"fileCreatedAt",
|
"fileCreatedAt",
|
||||||
"fileModifiedAt",
|
"fileModifiedAt",
|
||||||
"id",
|
"id",
|
||||||
|
@ -352,6 +352,7 @@ export const columns = {
|
|||||||
'isFavorite',
|
'isFavorite',
|
||||||
'visibility',
|
'visibility',
|
||||||
'updateId',
|
'updateId',
|
||||||
|
'duration',
|
||||||
],
|
],
|
||||||
stack: ['stack.id', 'stack.primaryAssetId', 'ownerId'],
|
stack: ['stack.id', 'stack.primaryAssetId', 'ownerId'],
|
||||||
syncAssetExif: [
|
syncAssetExif: [
|
||||||
|
@ -65,6 +65,7 @@ export class SyncAssetV1 {
|
|||||||
fileCreatedAt!: Date | null;
|
fileCreatedAt!: Date | null;
|
||||||
fileModifiedAt!: Date | null;
|
fileModifiedAt!: Date | null;
|
||||||
localDateTime!: Date | null;
|
localDateTime!: Date | null;
|
||||||
|
duration!: string | null;
|
||||||
@ApiProperty({ enumName: 'AssetTypeEnum', enum: AssetType })
|
@ApiProperty({ enumName: 'AssetTypeEnum', enum: AssetType })
|
||||||
type!: AssetType;
|
type!: AssetType;
|
||||||
deletedAt!: Date | null;
|
deletedAt!: Date | null;
|
||||||
|
@ -86,7 +86,8 @@ select
|
|||||||
"deletedAt",
|
"deletedAt",
|
||||||
"isFavorite",
|
"isFavorite",
|
||||||
"visibility",
|
"visibility",
|
||||||
"updateId"
|
"updateId",
|
||||||
|
"duration"
|
||||||
from
|
from
|
||||||
"assets"
|
"assets"
|
||||||
where
|
where
|
||||||
@ -109,7 +110,8 @@ select
|
|||||||
"deletedAt",
|
"deletedAt",
|
||||||
"isFavorite",
|
"isFavorite",
|
||||||
"visibility",
|
"visibility",
|
||||||
"updateId"
|
"updateId",
|
||||||
|
"duration"
|
||||||
from
|
from
|
||||||
"assets"
|
"assets"
|
||||||
where
|
where
|
||||||
|
@ -38,6 +38,7 @@ describe.concurrent(SyncEntityType.AssetV1, () => {
|
|||||||
fileModifiedAt: date,
|
fileModifiedAt: date,
|
||||||
localDateTime: date,
|
localDateTime: date,
|
||||||
deletedAt: null,
|
deletedAt: null,
|
||||||
|
duration: '0:10:00.00000',
|
||||||
});
|
});
|
||||||
await assetRepo.create(asset);
|
await assetRepo.create(asset);
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ describe.concurrent(SyncEntityType.AssetV1, () => {
|
|||||||
localDateTime: asset.localDateTime,
|
localDateTime: asset.localDateTime,
|
||||||
type: asset.type,
|
type: asset.type,
|
||||||
visibility: asset.visibility,
|
visibility: asset.visibility,
|
||||||
|
duration: asset.duration,
|
||||||
},
|
},
|
||||||
type: 'AssetV1',
|
type: 'AssetV1',
|
||||||
},
|
},
|
||||||
|
@ -42,6 +42,7 @@ describe.concurrent(SyncRequestType.PartnerAssetsV1, () => {
|
|||||||
fileModifiedAt: date,
|
fileModifiedAt: date,
|
||||||
localDateTime: date,
|
localDateTime: date,
|
||||||
deletedAt: null,
|
deletedAt: null,
|
||||||
|
duration: '0:10:00.00000',
|
||||||
});
|
});
|
||||||
await assetRepo.create(asset);
|
await assetRepo.create(asset);
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ describe.concurrent(SyncRequestType.PartnerAssetsV1, () => {
|
|||||||
localDateTime: date,
|
localDateTime: date,
|
||||||
type: asset.type,
|
type: asset.type,
|
||||||
visibility: asset.visibility,
|
visibility: asset.visibility,
|
||||||
|
duration: asset.duration,
|
||||||
},
|
},
|
||||||
type: SyncEntityType.PartnerAssetV1,
|
type: SyncEntityType.PartnerAssetV1,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user