mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat: sync albums and album users (#18377)
This commit is contained in:
parent
58af574241
commit
cd288533a1
41 changed files with 2811 additions and 934 deletions
|
|
@ -6,7 +6,9 @@ insert into
|
|||
values
|
||||
($1, $2)
|
||||
returning
|
||||
*
|
||||
"usersId",
|
||||
"albumsId",
|
||||
"role"
|
||||
|
||||
-- AlbumUserRepository.update
|
||||
update "albums_shared_users_users"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue