mirror of
https://github.com/immich-app/immich.git
synced 2025-01-04 02:46:47 +01: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
5 changed files with 5 additions and 17 deletions
|
@ -134,8 +134,6 @@ export interface AssetFullSyncOptions {
|
||||||
lastCreationDate?: Date;
|
lastCreationDate?: Date;
|
||||||
lastId?: string;
|
lastId?: string;
|
||||||
updatedUntil: Date;
|
updatedUntil: Date;
|
||||||
isArchived?: false;
|
|
||||||
withStacked?: true;
|
|
||||||
limit: number;
|
limit: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1059,8 +1059,4 @@ FROM
|
||||||
WHERE
|
WHERE
|
||||||
"asset"."isVisible" = true
|
"asset"."isVisible" = true
|
||||||
AND "asset"."ownerId" IN ($1)
|
AND "asset"."ownerId" IN ($1)
|
||||||
AND (
|
|
||||||
"stack"."primaryAssetId" = "asset"."id"
|
|
||||||
OR "asset"."stackId" IS NULL
|
|
||||||
)
|
|
||||||
AND "asset"."updatedAt" > $2
|
AND "asset"."updatedAt" > $2
|
||||||
|
|
|
@ -741,12 +741,11 @@ export class AssetRepository implements IAssetRepository {
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
getAllForUserFullSync(options: AssetFullSyncOptions): Promise<AssetEntity[]> {
|
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({
|
const builder = this.getBuilder({
|
||||||
userIds: [ownerId],
|
userIds: [ownerId],
|
||||||
exifInfo: true,
|
exifInfo: true, // also joins stack information
|
||||||
withStacked,
|
withStacked: false, // return all assets individually as expected by the app
|
||||||
isArchived,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (lastCreationDate !== undefined && lastId !== undefined) {
|
if (lastCreationDate !== undefined && lastId !== undefined) {
|
||||||
|
@ -767,9 +766,9 @@ export class AssetRepository implements IAssetRepository {
|
||||||
|
|
||||||
@GenerateSql({ params: [{ userIds: [DummyValue.UUID], updatedAfter: DummyValue.DATE }] })
|
@GenerateSql({ params: [{ userIds: [DummyValue.UUID], updatedAfter: DummyValue.DATE }] })
|
||||||
getChangedDeltaSync(options: AssetDeltaSyncOptions): Promise<AssetEntity[]> {
|
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) })
|
.andWhere({ updatedAt: MoreThan(options.updatedAfter) })
|
||||||
.take(options.limit)
|
.limit(options.limit)
|
||||||
.withDeleted();
|
.withDeleted();
|
||||||
|
|
||||||
return builder.getMany();
|
return builder.getMany();
|
||||||
|
|
|
@ -44,7 +44,6 @@ describe(SyncService.name, () => {
|
||||||
mapAsset(assetStub.hasEncodedVideo, mapAssetOpts),
|
mapAsset(assetStub.hasEncodedVideo, mapAssetOpts),
|
||||||
]);
|
]);
|
||||||
expect(assetMock.getAllForUserFullSync).toHaveBeenCalledWith({
|
expect(assetMock.getAllForUserFullSync).toHaveBeenCalledWith({
|
||||||
withStacked: true,
|
|
||||||
ownerId: authStub.user1.user.id,
|
ownerId: authStub.user1.user.id,
|
||||||
updatedUntil: untilDate,
|
updatedUntil: untilDate,
|
||||||
limit: 2,
|
limit: 2,
|
||||||
|
|
|
@ -32,10 +32,6 @@ export class SyncService {
|
||||||
await this.access.requirePermission(auth, Permission.TIMELINE_READ, userId);
|
await this.access.requirePermission(auth, Permission.TIMELINE_READ, userId);
|
||||||
const assets = await this.assetRepository.getAllForUserFullSync({
|
const assets = await this.assetRepository.getAllForUserFullSync({
|
||||||
ownerId: userId,
|
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,
|
lastCreationDate: dto.lastCreationDate,
|
||||||
updatedUntil: dto.updatedUntil,
|
updatedUntil: dto.updatedUntil,
|
||||||
lastId: dto.lastId,
|
lastId: dto.lastId,
|
||||||
|
|
Loading…
Reference in a new issue