mirror of
https://github.com/zebrajr/immich.git
synced 2025-12-06 12:20:54 +01: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()),
|
||||
createdAt: Value.absentIfNull(asset.fileCreatedAt),
|
||||
updatedAt: Value.absentIfNull(asset.fileModifiedAt),
|
||||
durationInSeconds: const Value(0),
|
||||
durationInSeconds:
|
||||
Value(asset.duration?.toDuration()?.inSeconds ?? 0),
|
||||
checksum: Value(asset.checksum),
|
||||
isFavorite: Value(asset.isFavorite),
|
||||
ownerId: Value(asset.ownerId),
|
||||
|
|
@ -251,3 +252,17 @@ extension on api.AssetVisibility {
|
|||
_ => 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
mobile/openapi/lib/model/sync_asset_v1.dart
generated
BIN
mobile/openapi/lib/model/sync_asset_v1.dart
generated
Binary file not shown.
|
|
@ -13622,6 +13622,10 @@
|
|||
"nullable": true,
|
||||
"type": "string"
|
||||
},
|
||||
"duration": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
},
|
||||
"fileCreatedAt": {
|
||||
"format": "date-time",
|
||||
"nullable": true,
|
||||
|
|
@ -13671,6 +13675,7 @@
|
|||
"required": [
|
||||
"checksum",
|
||||
"deletedAt",
|
||||
"duration",
|
||||
"fileCreatedAt",
|
||||
"fileModifiedAt",
|
||||
"id",
|
||||
|
|
|
|||
|
|
@ -352,6 +352,7 @@ export const columns = {
|
|||
'isFavorite',
|
||||
'visibility',
|
||||
'updateId',
|
||||
'duration',
|
||||
],
|
||||
stack: ['stack.id', 'stack.primaryAssetId', 'ownerId'],
|
||||
syncAssetExif: [
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ export class SyncAssetV1 {
|
|||
fileCreatedAt!: Date | null;
|
||||
fileModifiedAt!: Date | null;
|
||||
localDateTime!: Date | null;
|
||||
duration!: string | null;
|
||||
@ApiProperty({ enumName: 'AssetTypeEnum', enum: AssetType })
|
||||
type!: AssetType;
|
||||
deletedAt!: Date | null;
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ select
|
|||
"deletedAt",
|
||||
"isFavorite",
|
||||
"visibility",
|
||||
"updateId"
|
||||
"updateId",
|
||||
"duration"
|
||||
from
|
||||
"assets"
|
||||
where
|
||||
|
|
@ -109,7 +110,8 @@ select
|
|||
"deletedAt",
|
||||
"isFavorite",
|
||||
"visibility",
|
||||
"updateId"
|
||||
"updateId",
|
||||
"duration"
|
||||
from
|
||||
"assets"
|
||||
where
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ describe.concurrent(SyncEntityType.AssetV1, () => {
|
|||
fileModifiedAt: date,
|
||||
localDateTime: date,
|
||||
deletedAt: null,
|
||||
duration: '0:10:00.00000',
|
||||
});
|
||||
await assetRepo.create(asset);
|
||||
|
||||
|
|
@ -61,6 +62,7 @@ describe.concurrent(SyncEntityType.AssetV1, () => {
|
|||
localDateTime: asset.localDateTime,
|
||||
type: asset.type,
|
||||
visibility: asset.visibility,
|
||||
duration: asset.duration,
|
||||
},
|
||||
type: 'AssetV1',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ describe.concurrent(SyncRequestType.PartnerAssetsV1, () => {
|
|||
fileModifiedAt: date,
|
||||
localDateTime: date,
|
||||
deletedAt: null,
|
||||
duration: '0:10:00.00000',
|
||||
});
|
||||
await assetRepo.create(asset);
|
||||
|
||||
|
|
@ -68,6 +69,7 @@ describe.concurrent(SyncRequestType.PartnerAssetsV1, () => {
|
|||
localDateTime: date,
|
||||
type: asset.type,
|
||||
visibility: asset.visibility,
|
||||
duration: asset.duration,
|
||||
},
|
||||
type: SyncEntityType.PartnerAssetV1,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user