chore: asset sync FKs (#19927)

This commit is contained in:
Jason Rasmussen 2025-07-14 11:57:25 -04:00 committed by GitHub
parent a97ba4862f
commit 805ec3e351
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 59 additions and 1 deletions

View File

@ -20,9 +20,11 @@ class SyncAssetV1 {
required this.fileModifiedAt, required this.fileModifiedAt,
required this.id, required this.id,
required this.isFavorite, required this.isFavorite,
required this.livePhotoVideoId,
required this.localDateTime, required this.localDateTime,
required this.originalFileName, required this.originalFileName,
required this.ownerId, required this.ownerId,
required this.stackId,
required this.thumbhash, required this.thumbhash,
required this.type, required this.type,
required this.visibility, required this.visibility,
@ -42,12 +44,16 @@ class SyncAssetV1 {
bool isFavorite; bool isFavorite;
String? livePhotoVideoId;
DateTime? localDateTime; DateTime? localDateTime;
String originalFileName; String originalFileName;
String ownerId; String ownerId;
String? stackId;
String? thumbhash; String? thumbhash;
AssetTypeEnum type; AssetTypeEnum type;
@ -63,9 +69,11 @@ class SyncAssetV1 {
other.fileModifiedAt == fileModifiedAt && other.fileModifiedAt == fileModifiedAt &&
other.id == id && other.id == id &&
other.isFavorite == isFavorite && other.isFavorite == isFavorite &&
other.livePhotoVideoId == livePhotoVideoId &&
other.localDateTime == localDateTime && other.localDateTime == localDateTime &&
other.originalFileName == originalFileName && other.originalFileName == originalFileName &&
other.ownerId == ownerId && other.ownerId == ownerId &&
other.stackId == stackId &&
other.thumbhash == thumbhash && other.thumbhash == thumbhash &&
other.type == type && other.type == type &&
other.visibility == visibility; other.visibility == visibility;
@ -80,15 +88,17 @@ class SyncAssetV1 {
(fileModifiedAt == null ? 0 : fileModifiedAt!.hashCode) + (fileModifiedAt == null ? 0 : fileModifiedAt!.hashCode) +
(id.hashCode) + (id.hashCode) +
(isFavorite.hashCode) + (isFavorite.hashCode) +
(livePhotoVideoId == null ? 0 : livePhotoVideoId!.hashCode) +
(localDateTime == null ? 0 : localDateTime!.hashCode) + (localDateTime == null ? 0 : localDateTime!.hashCode) +
(originalFileName.hashCode) + (originalFileName.hashCode) +
(ownerId.hashCode) + (ownerId.hashCode) +
(stackId == null ? 0 : stackId!.hashCode) +
(thumbhash == null ? 0 : thumbhash!.hashCode) + (thumbhash == null ? 0 : thumbhash!.hashCode) +
(type.hashCode) + (type.hashCode) +
(visibility.hashCode); (visibility.hashCode);
@override @override
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]'; String toString() => 'SyncAssetV1[checksum=$checksum, deletedAt=$deletedAt, duration=$duration, fileCreatedAt=$fileCreatedAt, fileModifiedAt=$fileModifiedAt, id=$id, isFavorite=$isFavorite, livePhotoVideoId=$livePhotoVideoId, localDateTime=$localDateTime, originalFileName=$originalFileName, ownerId=$ownerId, stackId=$stackId, thumbhash=$thumbhash, type=$type, visibility=$visibility]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@ -115,6 +125,11 @@ class SyncAssetV1 {
} }
json[r'id'] = this.id; json[r'id'] = this.id;
json[r'isFavorite'] = this.isFavorite; json[r'isFavorite'] = this.isFavorite;
if (this.livePhotoVideoId != null) {
json[r'livePhotoVideoId'] = this.livePhotoVideoId;
} else {
// json[r'livePhotoVideoId'] = null;
}
if (this.localDateTime != null) { if (this.localDateTime != null) {
json[r'localDateTime'] = this.localDateTime!.toUtc().toIso8601String(); json[r'localDateTime'] = this.localDateTime!.toUtc().toIso8601String();
} else { } else {
@ -122,6 +137,11 @@ class SyncAssetV1 {
} }
json[r'originalFileName'] = this.originalFileName; json[r'originalFileName'] = this.originalFileName;
json[r'ownerId'] = this.ownerId; json[r'ownerId'] = this.ownerId;
if (this.stackId != null) {
json[r'stackId'] = this.stackId;
} else {
// json[r'stackId'] = null;
}
if (this.thumbhash != null) { if (this.thumbhash != null) {
json[r'thumbhash'] = this.thumbhash; json[r'thumbhash'] = this.thumbhash;
} else { } else {
@ -148,9 +168,11 @@ class SyncAssetV1 {
fileModifiedAt: mapDateTime(json, r'fileModifiedAt', r''), fileModifiedAt: mapDateTime(json, r'fileModifiedAt', r''),
id: mapValueOfType<String>(json, r'id')!, id: mapValueOfType<String>(json, r'id')!,
isFavorite: mapValueOfType<bool>(json, r'isFavorite')!, isFavorite: mapValueOfType<bool>(json, r'isFavorite')!,
livePhotoVideoId: mapValueOfType<String>(json, r'livePhotoVideoId'),
localDateTime: mapDateTime(json, r'localDateTime', r''), localDateTime: mapDateTime(json, r'localDateTime', r''),
originalFileName: mapValueOfType<String>(json, r'originalFileName')!, originalFileName: mapValueOfType<String>(json, r'originalFileName')!,
ownerId: mapValueOfType<String>(json, r'ownerId')!, ownerId: mapValueOfType<String>(json, r'ownerId')!,
stackId: mapValueOfType<String>(json, r'stackId'),
thumbhash: mapValueOfType<String>(json, r'thumbhash'), thumbhash: mapValueOfType<String>(json, r'thumbhash'),
type: AssetTypeEnum.fromJson(json[r'type'])!, type: AssetTypeEnum.fromJson(json[r'type'])!,
visibility: AssetVisibility.fromJson(json[r'visibility'])!, visibility: AssetVisibility.fromJson(json[r'visibility'])!,
@ -208,9 +230,11 @@ class SyncAssetV1 {
'fileModifiedAt', 'fileModifiedAt',
'id', 'id',
'isFavorite', 'isFavorite',
'livePhotoVideoId',
'localDateTime', 'localDateTime',
'originalFileName', 'originalFileName',
'ownerId', 'ownerId',
'stackId',
'thumbhash', 'thumbhash',
'type', 'type',
'visibility', 'visibility',

View File

@ -13818,6 +13818,10 @@
"isFavorite": { "isFavorite": {
"type": "boolean" "type": "boolean"
}, },
"livePhotoVideoId": {
"nullable": true,
"type": "string"
},
"localDateTime": { "localDateTime": {
"format": "date-time", "format": "date-time",
"nullable": true, "nullable": true,
@ -13829,6 +13833,10 @@
"ownerId": { "ownerId": {
"type": "string" "type": "string"
}, },
"stackId": {
"nullable": true,
"type": "string"
},
"thumbhash": { "thumbhash": {
"nullable": true, "nullable": true,
"type": "string" "type": "string"
@ -13856,9 +13864,11 @@
"fileModifiedAt", "fileModifiedAt",
"id", "id",
"isFavorite", "isFavorite",
"livePhotoVideoId",
"localDateTime", "localDateTime",
"originalFileName", "originalFileName",
"ownerId", "ownerId",
"stackId",
"thumbhash", "thumbhash",
"type", "type",
"visibility" "visibility"

View File

@ -349,6 +349,8 @@ export const columns = {
'asset.isFavorite', 'asset.isFavorite',
'asset.visibility', 'asset.visibility',
'asset.duration', 'asset.duration',
'asset.livePhotoVideoId',
'asset.stackId',
], ],
syncAlbumUser: ['album_user.albumsId as albumId', 'album_user.usersId as userId', 'album_user.role'], syncAlbumUser: ['album_user.albumsId as albumId', 'album_user.usersId as userId', 'album_user.role'],
syncStack: ['stack.id', 'stack.createdAt', 'stack.updatedAt', 'stack.primaryAssetId', 'stack.ownerId'], syncStack: ['stack.id', 'stack.createdAt', 'stack.updatedAt', 'stack.primaryAssetId', 'stack.ownerId'],

View File

@ -96,6 +96,8 @@ export class SyncAssetV1 {
isFavorite!: boolean; isFavorite!: boolean;
@ApiProperty({ enumName: 'AssetVisibility', enum: AssetVisibility }) @ApiProperty({ enumName: 'AssetVisibility', enum: AssetVisibility })
visibility!: AssetVisibility; visibility!: AssetVisibility;
livePhotoVideoId!: string | null;
stackId!: string | null;
} }
@ExtraModel() @ExtraModel()

View File

@ -64,6 +64,8 @@ select
"asset"."isFavorite", "asset"."isFavorite",
"asset"."visibility", "asset"."visibility",
"asset"."duration", "asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."updateId" "asset"."updateId"
from from
"asset" "asset"
@ -91,6 +93,8 @@ select
"asset"."isFavorite", "asset"."isFavorite",
"asset"."visibility", "asset"."visibility",
"asset"."duration", "asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."updateId" "asset"."updateId"
from from
"asset" "asset"
@ -351,6 +355,8 @@ select
"asset"."isFavorite", "asset"."isFavorite",
"asset"."visibility", "asset"."visibility",
"asset"."duration", "asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."updateId" "asset"."updateId"
from from
"asset" "asset"
@ -539,6 +545,8 @@ select
"asset"."isFavorite", "asset"."isFavorite",
"asset"."visibility", "asset"."visibility",
"asset"."duration", "asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."updateId" "asset"."updateId"
from from
"asset" "asset"
@ -584,6 +592,8 @@ select
"asset"."isFavorite", "asset"."isFavorite",
"asset"."visibility", "asset"."visibility",
"asset"."duration", "asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."updateId" "asset"."updateId"
from from
"asset" "asset"

View File

@ -380,6 +380,8 @@ export class JobService extends BaseService {
deletedAt: asset.deletedAt, deletedAt: asset.deletedAt,
isFavorite: asset.isFavorite, isFavorite: asset.isFavorite,
visibility: asset.visibility, visibility: asset.visibility,
livePhotoVideoId: asset.livePhotoVideoId,
stackId: asset.stackId,
}, },
exif: { exif: {
assetId: exif.assetId, assetId: exif.assetId,

View File

@ -36,6 +36,8 @@ describe(SyncRequestType.AlbumAssetsV1, () => {
localDateTime: date, localDateTime: date,
deletedAt: null, deletedAt: null,
duration: '0:10:00.00000', duration: '0:10:00.00000',
livePhotoVideoId: null,
stackId: null,
}); });
const { album } = await ctx.newAlbum({ ownerId: user2.id }); const { album } = await ctx.newAlbum({ ownerId: user2.id });
await ctx.newAlbumAsset({ albumId: album.id, assetId: asset.id }); await ctx.newAlbumAsset({ albumId: album.id, assetId: asset.id });
@ -60,6 +62,8 @@ describe(SyncRequestType.AlbumAssetsV1, () => {
type: asset.type, type: asset.type,
visibility: asset.visibility, visibility: asset.visibility,
duration: asset.duration, duration: asset.duration,
livePhotoVideoId: asset.livePhotoVideoId,
stackId: asset.stackId,
}, },
type: SyncEntityType.AlbumAssetV1, type: SyncEntityType.AlbumAssetV1,
}, },

View File

@ -57,6 +57,8 @@ describe(SyncEntityType.AssetV1, () => {
type: asset.type, type: asset.type,
visibility: asset.visibility, visibility: asset.visibility,
duration: asset.duration, duration: asset.duration,
stackId: null,
livePhotoVideoId: null,
}, },
type: 'AssetV1', type: 'AssetV1',
}, },

View File

@ -63,6 +63,8 @@ describe(SyncRequestType.PartnerAssetsV1, () => {
type: asset.type, type: asset.type,
visibility: asset.visibility, visibility: asset.visibility,
duration: asset.duration, duration: asset.duration,
stackId: null,
livePhotoVideoId: null,
}, },
type: SyncEntityType.PartnerAssetV1, type: SyncEntityType.PartnerAssetV1,
}, },