Fix CPU usage on PostgreSQL
This commit is contained in:
parent
c06be12950
commit
49be0fd325
|
@ -136,8 +136,7 @@ import {
|
||||||
MVideoThumbnailBlacklist,
|
MVideoThumbnailBlacklist,
|
||||||
MVideoWithAllFiles,
|
MVideoWithAllFiles,
|
||||||
MVideoWithFile,
|
MVideoWithFile,
|
||||||
MVideoWithRights,
|
MVideoWithRights
|
||||||
MStreamingPlaylistFiles
|
|
||||||
} from '../../typings/models'
|
} from '../../typings/models'
|
||||||
import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file'
|
import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file'
|
||||||
import { MThumbnail } from '../../typings/models/video/thumbnail'
|
import { MThumbnail } from '../../typings/models/video/thumbnail'
|
||||||
|
@ -437,42 +436,31 @@ export type AvailableForListIDsOptions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.followerActorId) {
|
if (options.followerActorId) {
|
||||||
let localVideosReq: WhereOptions = {}
|
let localVideosReq = ''
|
||||||
if (options.includeLocalVideos === true) {
|
if (options.includeLocalVideos === true) {
|
||||||
localVideosReq = { remote: false }
|
localVideosReq = ' UNION ALL SELECT "video"."id" FROM "video" WHERE remote IS FALSE'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force actorId to be a number to avoid SQL injections
|
// Force actorId to be a number to avoid SQL injections
|
||||||
const actorIdNumber = parseInt(options.followerActorId.toString(), 10)
|
const actorIdNumber = parseInt(options.followerActorId.toString(), 10)
|
||||||
whereAnd.push({
|
whereAnd.push({
|
||||||
[Op.or]: [
|
id: {
|
||||||
{
|
[Op.in]: Sequelize.literal(
|
||||||
id: {
|
'(' +
|
||||||
[ Op.in ]: Sequelize.literal(
|
'SELECT "videoShare"."videoId" AS "id" FROM "videoShare" ' +
|
||||||
'(' +
|
'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' +
|
||||||
'SELECT "videoShare"."videoId" AS "id" FROM "videoShare" ' +
|
'WHERE "actorFollow"."actorId" = ' + actorIdNumber +
|
||||||
'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' +
|
' UNION ALL ' +
|
||||||
'WHERE "actorFollow"."actorId" = ' + actorIdNumber +
|
'SELECT "video"."id" AS "id" FROM "video" ' +
|
||||||
')'
|
'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
|
||||||
)
|
'INNER JOIN "account" ON "account"."id" = "videoChannel"."accountId" ' +
|
||||||
}
|
'INNER JOIN "actor" ON "account"."actorId" = "actor"."id" ' +
|
||||||
},
|
'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "actor"."id" ' +
|
||||||
{
|
'WHERE "actorFollow"."actorId" = ' + actorIdNumber +
|
||||||
id: {
|
localVideosReq +
|
||||||
[ Op.in ]: Sequelize.literal(
|
')'
|
||||||
'(' +
|
)
|
||||||
'SELECT "video"."id" AS "id" FROM "video" ' +
|
}
|
||||||
'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
|
|
||||||
'INNER JOIN "account" ON "account"."id" = "videoChannel"."accountId" ' +
|
|
||||||
'INNER JOIN "actor" ON "account"."actorId" = "actor"."id" ' +
|
|
||||||
'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "actor"."id" ' +
|
|
||||||
'WHERE "actorFollow"."actorId" = ' + actorIdNumber +
|
|
||||||
')'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
localVideosReq
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue