mirror of
https://github.com/immich-app/immich.git
synced 2025-01-20 16:42:43 +02:00
refactor: activity queries (#15207)
This commit is contained in:
parent
1fb2b3f899
commit
7d50d3032b
server/src
@ -31,11 +31,11 @@ select
|
||||
count(*) as "count"
|
||||
from
|
||||
"activity"
|
||||
left join "users" on "users"."id" = "activity"."userId"
|
||||
inner join "users" on "users"."id" = "activity"."userId"
|
||||
and "users"."deletedAt" is null
|
||||
left join "assets" on "assets"."id" = "activity"."assetId"
|
||||
where
|
||||
"activity"."assetId" = $1
|
||||
and "activity"."albumId" = $2
|
||||
and "activity"."isLiked" = $3
|
||||
and "users"."deletedAt" is null
|
||||
and "assets"."deletedAt" is null
|
||||
|
@ -60,12 +60,11 @@ export class ActivityRepository implements IActivityRepository {
|
||||
const { count } = await this.db
|
||||
.selectFrom('activity')
|
||||
.select((eb) => eb.fn.countAll().as('count'))
|
||||
.leftJoin('users', 'users.id', 'activity.userId')
|
||||
.innerJoin('users', (join) => join.onRef('users.id', '=', 'activity.userId').on('users.deletedAt', 'is', null))
|
||||
.leftJoin('assets', 'assets.id', 'activity.assetId')
|
||||
.$if(!!assetId, (qb) => qb.where('activity.assetId', '=', assetId!))
|
||||
.where('activity.albumId', '=', albumId)
|
||||
.where('activity.isLiked', '=', false)
|
||||
.where('users.deletedAt', 'is', null)
|
||||
.where('assets.deletedAt', 'is', null)
|
||||
.executeTakeFirstOrThrow();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user