2024-03-30 00:16:06 -04:00
|
|
|
-- NOTE: This file is auto generated by ./sql-generator
|
|
|
|
|
|
|
|
|
|
-- ActivityRepository.search
|
2025-01-09 20:31:46 +01:00
|
|
|
select
|
|
|
|
|
"activity".*,
|
2025-04-09 08:35:20 -04:00
|
|
|
to_json("user") as "user"
|
|
|
|
|
from
|
|
|
|
|
"activity"
|
2025-07-14 10:13:06 -04:00
|
|
|
inner join "user" as "user2" on "user2"."id" = "activity"."userId"
|
|
|
|
|
and "user2"."deletedAt" is null
|
2025-04-09 08:35:20 -04:00
|
|
|
inner join lateral (
|
|
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"user2"."id",
|
|
|
|
|
"user2"."name",
|
|
|
|
|
"user2"."email",
|
|
|
|
|
"user2"."avatarColor",
|
|
|
|
|
"user2"."profileImagePath",
|
|
|
|
|
"user2"."profileChangedAt"
|
2025-04-09 08:35:20 -04:00
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
1
|
|
|
|
|
) as "dummy"
|
|
|
|
|
) as "user" on true
|
2025-07-14 10:13:06 -04:00
|
|
|
left join "asset" on "asset"."id" = "activity"."assetId"
|
2025-04-09 08:35:20 -04:00
|
|
|
where
|
|
|
|
|
"activity"."albumId" = $1
|
2025-07-14 10:13:06 -04:00
|
|
|
and "asset"."deletedAt" is null
|
2025-04-09 08:35:20 -04:00
|
|
|
order by
|
|
|
|
|
"activity"."createdAt" asc
|
|
|
|
|
|
|
|
|
|
-- ActivityRepository.create
|
|
|
|
|
insert into
|
|
|
|
|
"activity" ("albumId", "userId")
|
|
|
|
|
values
|
|
|
|
|
($1, $2)
|
|
|
|
|
returning
|
|
|
|
|
*,
|
2024-04-25 23:45:15 +02:00
|
|
|
(
|
2025-01-09 20:31:46 +01:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
2024-04-25 23:45:15 +02:00
|
|
|
(
|
2025-01-09 20:31:46 +01:00
|
|
|
select
|
2025-01-15 23:31:26 -05:00
|
|
|
"id",
|
|
|
|
|
"name",
|
|
|
|
|
"email",
|
2025-04-28 09:54:51 -04:00
|
|
|
"avatarColor",
|
2025-01-15 23:31:26 -05:00
|
|
|
"profileImagePath",
|
|
|
|
|
"profileChangedAt"
|
2025-01-09 20:31:46 +01:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"user"
|
2025-01-09 20:31:46 +01:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"user"."id" = "activity"."userId"
|
2025-01-09 20:31:46 +01:00
|
|
|
) as obj
|
|
|
|
|
) as "user"
|
2025-04-09 08:35:20 -04:00
|
|
|
|
|
|
|
|
-- ActivityRepository.delete
|
|
|
|
|
delete from "activity"
|
2025-01-09 20:31:46 +01:00
|
|
|
where
|
2025-04-09 08:35:20 -04:00
|
|
|
"id" = $1::uuid
|
2024-03-30 00:16:06 -04:00
|
|
|
|
|
|
|
|
-- ActivityRepository.getStatistics
|
2025-01-09 20:31:46 +01:00
|
|
|
select
|
2025-06-04 19:41:50 +02:00
|
|
|
count(*) filter (
|
|
|
|
|
where
|
|
|
|
|
"activity"."isLiked" = $1
|
|
|
|
|
) as "comments",
|
|
|
|
|
count(*) filter (
|
|
|
|
|
where
|
|
|
|
|
"activity"."isLiked" = $2
|
|
|
|
|
) as "likes"
|
2025-01-09 20:31:46 +01:00
|
|
|
from
|
|
|
|
|
"activity"
|
2025-07-14 10:13:06 -04:00
|
|
|
inner join "user" on "user"."id" = "activity"."userId"
|
|
|
|
|
and "user"."deletedAt" is null
|
|
|
|
|
left join "asset" on "asset"."id" = "activity"."assetId"
|
2025-01-09 20:31:46 +01:00
|
|
|
where
|
2025-06-04 19:41:50 +02:00
|
|
|
"activity"."assetId" = $3
|
|
|
|
|
and "activity"."albumId" = $4
|
2025-06-11 16:50:26 +01:00
|
|
|
and (
|
|
|
|
|
(
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."deletedAt" is null
|
|
|
|
|
and "asset"."visibility" != 'locked'
|
2025-06-11 16:50:26 +01:00
|
|
|
)
|
2025-07-14 10:13:06 -04:00
|
|
|
or "asset"."id" is null
|
2025-06-11 16:50:26 +01:00
|
|
|
)
|