Optimize comment RSS sql query
This commit is contained in:
parent
1c5c31a1ce
commit
1c58423f6c
2 changed files with 40 additions and 14 deletions
|
@ -129,6 +129,30 @@ function buildBlockedAccountSQL (blockerIds: number[]) {
|
|||
'WHERE "serverBlocklist"."accountId" IN (' + blockerIdsString + ')'
|
||||
}
|
||||
|
||||
function buildBlockedAccountSQLOptimized (columnNameJoin: string, blockerIds: number[]) {
|
||||
const blockerIdsString = blockerIds.join(', ')
|
||||
|
||||
return [
|
||||
literal(
|
||||
`NOT EXISTS (` +
|
||||
` SELECT 1 FROM "accountBlocklist" ` +
|
||||
` WHERE "targetAccountId" = ${columnNameJoin} ` +
|
||||
` AND "accountId" IN (${blockerIdsString})` +
|
||||
`)`
|
||||
),
|
||||
|
||||
literal(
|
||||
`NOT EXISTS (` +
|
||||
` SELECT 1 FROM "account" ` +
|
||||
` INNER JOIN "actor" ON account."actorId" = actor.id ` +
|
||||
` INNER JOIN "serverBlocklist" ON "actor"."serverId" = "serverBlocklist"."targetServerId" ` +
|
||||
` WHERE "account"."id" = ${columnNameJoin} ` +
|
||||
` AND "serverBlocklist"."accountId" IN (${blockerIdsString})` +
|
||||
`)`
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
function buildServerIdsFollowedBy (actorId: any) {
|
||||
const actorIdNumber = parseInt(actorId + '', 10)
|
||||
|
||||
|
@ -201,6 +225,7 @@ function searchAttribute (sourceField?: string, targetField?: string) {
|
|||
|
||||
export {
|
||||
buildBlockedAccountSQL,
|
||||
buildBlockedAccountSQLOptimized,
|
||||
buildLocalActorIdsIn,
|
||||
SortType,
|
||||
buildLocalAccountIdsIn,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue