import { Sequelize } from 'sequelize'
import { BuildVideoGetQueryOptions } from '../video-model-get-query-builder'
-import { AbstractVideosModelQueryBuilder } from './abstract-videos-model-query-builder'
+import { AbstractVideoQueryBuilder } from './abstract-video-query-builder'
/**
*
*
*/
-export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
+export class VideoFileQueryBuilder extends AbstractVideoQueryBuilder {
protected attributes: { [key: string]: string }
- protected joins: string[] = []
constructor (protected readonly sequelize: Sequelize) {
super('get')
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) {
'"video"."id"': ''
}
- this.includeWebtorrentFiles(true)
+ this.includeWebtorrentFiles()
- if (options.forGetAPI === true) {
+ if (this.shouldIncludeRedundancies(options)) {
this.includeWebTorrentRedundancies()
}
- this.whereId(options.id)
+ this.whereId(options)
this.query = this.buildQuery()
}
'"video"."id"': ''
}
- this.includeStreamingPlaylistFiles(true)
+ this.includeStreamingPlaylistFiles()
- if (options.forGetAPI === true) {
+ if (this.shouldIncludeRedundancies(options)) {
this.includeStreamingPlaylistRedundancies()
}
- this.whereId(options.id)
+ this.whereId(options)
this.query = this.buildQuery()
}
private buildQuery () {
- return `${this.buildSelect()} FROM "video" ${this.joins.join(' ')} ${this.where}`
+ return `${this.buildSelect()} FROM "video" ${this.joins} ${this.where}`
+ }
+
+ private shouldIncludeRedundancies (options: BuildVideoGetQueryOptions) {
+ return options.type === 'api'
}
}