1
0
Fork 0

Fix and cleanup actor follow inbox sql query

This commit is contained in:
Chocobozzz 2019-10-23 12:06:26 +02:00
parent 8ed11b89b8
commit 862ead21a3
No known key found for this signature in database
GPG key ID: 583A612D890159BE

View file

@ -574,8 +574,8 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
} }
const selections: string[] = [] const selections: string[] = []
if (distinct === true) selections.push('DISTINCT("Follows"."' + columnUrl + '") AS "selectionUrl"') if (distinct === true) selections.push(`DISTINCT("Follows"."${columnUrl}") AS "selectionUrl"`)
else selections.push('"Follows"."' + columnUrl + '" AS "selectionUrl"') else selections.push(`"Follows"."${columnUrl}" AS "selectionUrl"`)
selections.push('COUNT(*) AS "total"') selections.push('COUNT(*) AS "total"')
@ -585,7 +585,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
let query = 'SELECT ' + selection + ' FROM "actor" ' + let query = 'SELECT ' + selection + ' FROM "actor" ' +
'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' + 'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' +
'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' + 'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' +
'WHERE "actor"."id" = ANY ($actorIds) AND "actorFollow"."state" = \'accepted\' AND "selectionUrl" IS NOT NULL ' `WHERE "actor"."id" = ANY ($actorIds) AND "actorFollow"."state" = 'accepted' AND "Follows"."${columnUrl}" IS NOT NULL `
if (count !== undefined) query += 'LIMIT ' + count if (count !== undefined) query += 'LIMIT ' + count
if (start !== undefined) query += ' OFFSET ' + start if (start !== undefined) query += ' OFFSET ' + start