mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor: activity item (#17470)
* refactor: activity item * fix query * qualified columns --------- Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
This commit is contained in:
parent
ae8af84101
commit
cf2c0260a6
7 changed files with 81 additions and 44 deletions
|
|
@ -3,6 +3,38 @@
|
|||
-- ActivityRepository.search
|
||||
select
|
||||
"activity".*,
|
||||
to_json("user") as "user"
|
||||
from
|
||||
"activity"
|
||||
inner join "users" on "users"."id" = "activity"."userId"
|
||||
and "users"."deletedAt" is null
|
||||
inner join lateral (
|
||||
select
|
||||
"users"."id",
|
||||
"users"."name",
|
||||
"users"."email",
|
||||
"users"."profileImagePath",
|
||||
"users"."profileChangedAt"
|
||||
from
|
||||
(
|
||||
select
|
||||
1
|
||||
) as "dummy"
|
||||
) as "user" on true
|
||||
left join "assets" on "assets"."id" = "activity"."assetId"
|
||||
and "assets"."deletedAt" is null
|
||||
where
|
||||
"activity"."albumId" = $1
|
||||
order by
|
||||
"activity"."createdAt" asc
|
||||
|
||||
-- ActivityRepository.create
|
||||
insert into
|
||||
"activity" ("albumId", "userId")
|
||||
values
|
||||
($1, $2)
|
||||
returning
|
||||
*,
|
||||
(
|
||||
select
|
||||
to_json(obj)
|
||||
|
|
@ -18,17 +50,13 @@ select
|
|||
"users"
|
||||
where
|
||||
"users"."id" = "activity"."userId"
|
||||
and "users"."deletedAt" is null
|
||||
) as obj
|
||||
) as "user"
|
||||
from
|
||||
"activity"
|
||||
left join "assets" on "assets"."id" = "activity"."assetId"
|
||||
and "assets"."deletedAt" is null
|
||||
|
||||
-- ActivityRepository.delete
|
||||
delete from "activity"
|
||||
where
|
||||
"activity"."albumId" = $1
|
||||
order by
|
||||
"activity"."createdAt" asc
|
||||
"id" = $1::uuid
|
||||
|
||||
-- ActivityRepository.getStatistics
|
||||
select
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue