mirror of
https://github.com/immich-app/immich.git
synced 2024-11-24 08:52:28 +02:00
fix(server): new full sync return stacked assets individually (#9189)
* fix(server): new full sync return stacked assets individually * return archived partner assets (like old getAllAssets) * fix * fix test --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
77b8c2f330
commit
4d7aa7effd
@ -134,8 +134,6 @@ export interface AssetFullSyncOptions {
|
||||
lastCreationDate?: Date;
|
||||
lastId?: string;
|
||||
updatedUntil: Date;
|
||||
isArchived?: false;
|
||||
withStacked?: true;
|
||||
limit: number;
|
||||
}
|
||||
|
||||
|
@ -1059,8 +1059,4 @@ FROM
|
||||
WHERE
|
||||
"asset"."isVisible" = true
|
||||
AND "asset"."ownerId" IN ($1)
|
||||
AND (
|
||||
"stack"."primaryAssetId" = "asset"."id"
|
||||
OR "asset"."stackId" IS NULL
|
||||
)
|
||||
AND "asset"."updatedAt" > $2
|
||||
|
@ -741,12 +741,11 @@ export class AssetRepository implements IAssetRepository {
|
||||
],
|
||||
})
|
||||
getAllForUserFullSync(options: AssetFullSyncOptions): Promise<AssetEntity[]> {
|
||||
const { ownerId, isArchived, withStacked, lastCreationDate, lastId, updatedUntil, limit } = options;
|
||||
const { ownerId, lastCreationDate, lastId, updatedUntil, limit } = options;
|
||||
const builder = this.getBuilder({
|
||||
userIds: [ownerId],
|
||||
exifInfo: true,
|
||||
withStacked,
|
||||
isArchived,
|
||||
exifInfo: true, // also joins stack information
|
||||
withStacked: false, // return all assets individually as expected by the app
|
||||
});
|
||||
|
||||
if (lastCreationDate !== undefined && lastId !== undefined) {
|
||||
@ -767,9 +766,9 @@ export class AssetRepository implements IAssetRepository {
|
||||
|
||||
@GenerateSql({ params: [{ userIds: [DummyValue.UUID], updatedAfter: DummyValue.DATE }] })
|
||||
getChangedDeltaSync(options: AssetDeltaSyncOptions): Promise<AssetEntity[]> {
|
||||
const builder = this.getBuilder({ userIds: options.userIds, exifInfo: true, withStacked: true })
|
||||
const builder = this.getBuilder({ userIds: options.userIds, exifInfo: true, withStacked: false })
|
||||
.andWhere({ updatedAt: MoreThan(options.updatedAfter) })
|
||||
.take(options.limit)
|
||||
.limit(options.limit)
|
||||
.withDeleted();
|
||||
|
||||
return builder.getMany();
|
||||
|
@ -44,7 +44,6 @@ describe(SyncService.name, () => {
|
||||
mapAsset(assetStub.hasEncodedVideo, mapAssetOpts),
|
||||
]);
|
||||
expect(assetMock.getAllForUserFullSync).toHaveBeenCalledWith({
|
||||
withStacked: true,
|
||||
ownerId: authStub.user1.user.id,
|
||||
updatedUntil: untilDate,
|
||||
limit: 2,
|
||||
|
@ -32,10 +32,6 @@ export class SyncService {
|
||||
await this.access.requirePermission(auth, Permission.TIMELINE_READ, userId);
|
||||
const assets = await this.assetRepository.getAllForUserFullSync({
|
||||
ownerId: userId,
|
||||
// no archived assets for partner user
|
||||
isArchived: userId === auth.user.id ? undefined : false,
|
||||
// no stack for partner user
|
||||
withStacked: userId === auth.user.id ? true : undefined,
|
||||
lastCreationDate: dto.lastCreationDate,
|
||||
updatedUntil: dto.updatedUntil,
|
||||
lastId: dto.lastId,
|
||||
|
Loading…
Reference in New Issue
Block a user