]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/sql/shared/video-file-query-builder.ts
Use raw SQL for most of video queries
[github/Chocobozzz/PeerTube.git] / server / models / video / sql / shared / video-file-query-builder.ts
index 7d822f8fabf96199f7eaa883d9a8b871290eeffa..a62fa64f842c63733d61c520c31c26802ad38dce 100644 (file)
@@ -18,13 +18,13 @@ export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
   queryWebTorrentVideos (options: BuildVideoGetQueryOptions) {
     this.buildWebtorrentFilesQuery(options)
 
-    return this.runQuery(options.transaction)
+    return this.runQuery(options)
   }
 
   queryStreamingPlaylistVideos (options: BuildVideoGetQueryOptions) {
     this.buildVideoStreamingPlaylistFilesQuery(options)
 
-    return this.runQuery(options.transaction)
+    return this.runQuery(options)
   }
 
   private buildWebtorrentFilesQuery (options: BuildVideoGetQueryOptions) {
@@ -34,11 +34,11 @@ export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
 
     this.includeWebtorrentFiles(true)
 
-    if (options.forGetAPI === true) {
+    if (this.shouldIncludeRedundancies(options)) {
       this.includeWebTorrentRedundancies()
     }
 
-    this.whereId(options.id)
+    this.whereId(options)
 
     this.query = this.buildQuery()
   }
@@ -50,11 +50,11 @@ export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
 
     this.includeStreamingPlaylistFiles(true)
 
-    if (options.forGetAPI === true) {
+    if (this.shouldIncludeRedundancies(options)) {
       this.includeStreamingPlaylistRedundancies()
     }
 
-    this.whereId(options.id)
+    this.whereId(options)
 
     this.query = this.buildQuery()
   }
@@ -62,4 +62,8 @@ export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
   private buildQuery () {
     return `${this.buildSelect()} FROM "video" ${this.joins} ${this.where}`
   }
+
+  private shouldIncludeRedundancies (options: BuildVideoGetQueryOptions) {
+    return options.type === 'api'
+  }
 }