feat: sync albums and album users (#18377)

This commit is contained in:
Jason Rasmussen 2025-05-21 15:35:32 -04:00 committed by GitHub
parent 58af574241
commit cd288533a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 2811 additions and 934 deletions

View file

@ -6,7 +6,9 @@ insert into
values
($1, $2)
returning
*
"usersId",
"albumsId",
"role"
-- AlbumUserRepository.update
update "albums_shared_users_users"

View file

@ -246,3 +246,98 @@ where
and "updatedAt" < now() - interval '1 millisecond'
order by
"updateId" asc
-- SyncRepository.getAlbumDeletes
select
"id",
"albumId"
from
"albums_audit"
where
"userId" = $1
and "deletedAt" < now() - interval '1 millisecond'
order by
"id" asc
-- SyncRepository.getAlbumUpserts
select distinct
on ("albums"."id", "albums"."updateId") "albums"."id",
"albums"."ownerId",
"albums"."albumName" as "name",
"albums"."description",
"albums"."createdAt",
"albums"."updatedAt",
"albums"."albumThumbnailAssetId" as "thumbnailAssetId",
"albums"."isActivityEnabled",
"albums"."order",
"albums"."updateId"
from
"albums"
left join "albums_shared_users_users" as "album_users" on "albums"."id" = "album_users"."albumsId"
where
"albums"."updatedAt" < now() - interval '1 millisecond'
and (
"albums"."ownerId" = $1
or "album_users"."usersId" = $2
)
order by
"albums"."updateId" asc
-- SyncRepository.getAlbumUserDeletes
select
"id",
"userId",
"albumId"
from
"album_users_audit"
where
"albumId" in (
select
"id"
from
"albums"
where
"ownerId" = $1
union
(
select
"albumUsers"."albumsId" as "id"
from
"albums_shared_users_users" as "albumUsers"
where
"albumUsers"."usersId" = $2
)
)
and "deletedAt" < now() - interval '1 millisecond'
order by
"id" asc
-- SyncRepository.getAlbumUserUpserts
select
"albums_shared_users_users"."albumsId" as "albumId",
"albums_shared_users_users"."usersId" as "userId",
"albums_shared_users_users"."role",
"albums_shared_users_users"."updateId"
from
"albums_shared_users_users"
where
"albums_shared_users_users"."updatedAt" < now() - interval '1 millisecond'
and "albums_shared_users_users"."albumsId" in (
select
"id"
from
"albums"
where
"ownerId" = $1
union
(
select
"albumUsers"."albumsId" as "id"
from
"albums_shared_users_users" as "albumUsers"
where
"albumUsers"."usersId" = $2
)
)
order by
"albums_shared_users_users"."updateId" asc