aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/sql/videos-model-list-query-builder.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-11 11:27:45 +0200
committerChocobozzz <me@florianbigard.com>2021-06-11 11:27:45 +0200
commit3c79c2ce86eaf9e151ab6c2c9d1f646968a16744 (patch)
treefa7e993359e070395a45ecb7a19e9c580d88ff61 /server/models/video/sql/videos-model-list-query-builder.ts
parent17bb45388ec319d288a1b8387c6c199fe2f6b64f (diff)
downloadPeerTube-3c79c2ce86eaf9e151ab6c2c9d1f646968a16744.tar.gz
PeerTube-3c79c2ce86eaf9e151ab6c2c9d1f646968a16744.tar.zst
PeerTube-3c79c2ce86eaf9e151ab6c2c9d1f646968a16744.zip
Optimize join build
Diffstat (limited to 'server/models/video/sql/videos-model-list-query-builder.ts')
-rw-r--r--server/models/video/sql/videos-model-list-query-builder.ts5
1 files changed, 2 insertions, 3 deletions
diff --git a/server/models/video/sql/videos-model-list-query-builder.ts b/server/models/video/sql/videos-model-list-query-builder.ts
index 459f542a4..d3a9a9466 100644
--- a/server/models/video/sql/videos-model-list-query-builder.ts
+++ b/server/models/video/sql/videos-model-list-query-builder.ts
@@ -11,7 +11,6 @@ import { BuildVideosListQueryOptions, VideosIdListQueryBuilder } from './videos-
11 11
12export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder { 12export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder {
13 protected attributes: { [key: string]: string } 13 protected attributes: { [key: string]: string }
14 protected joins: string[] = []
15 14
16 private innerQuery: string 15 private innerQuery: string
17 private innerSort: string 16 private innerSort: string
@@ -45,7 +44,7 @@ export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder
45 '"video".*': '' 44 '"video".*': ''
46 } 45 }
47 46
48 this.joins = [ 'INNER JOIN "video" ON "tmp"."id" = "video"."id"' ] 47 this.addJoin('INNER JOIN "video" ON "tmp"."id" = "video"."id"')
49 48
50 this.includeChannels() 49 this.includeChannels()
51 this.includeAccounts() 50 this.includeAccounts()
@@ -66,6 +65,6 @@ export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder
66 65
67 const select = this.buildSelect() 66 const select = this.buildSelect()
68 67
69 this.query = `${select} FROM (${this.innerQuery}) AS "tmp" ${this.joins.join(' ')} ${this.innerSort}` 68 this.query = `${select} FROM (${this.innerQuery}) AS "tmp" ${this.joins} ${this.innerSort}`
70 } 69 }
71} 70}