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

View File

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

View File

@ -349,6 +349,8 @@ export const columns = {
'asset.isFavorite',
'asset.visibility',
'asset.duration',
'asset.livePhotoVideoId',
'asset.stackId',
],
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'],

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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