Skip to content

Commit

Permalink
fix(server): new full sync return stacked assets individually (#9189)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
fyfrey and alextran1502 committed May 14, 2024
1 parent 77b8c2f commit 4d7aa7e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 17 deletions.
2 changes: 0 additions & 2 deletions server/src/interfaces/asset.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ export interface AssetFullSyncOptions {
lastCreationDate?: Date;
lastId?: string;
updatedUntil: Date;
isArchived?: false;
withStacked?: true;
limit: number;
}

Expand Down
4 changes: 0 additions & 4 deletions server/src/queries/asset.repository.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 5 additions & 6 deletions server/src/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
Expand Down
1 change: 0 additions & 1 deletion server/src/services/sync.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions server/src/services/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4d7aa7e

Please sign in to comment.