import { Sequelize } from 'sequelize'
import { AbstractVideosModelQueryBuilder } from './shared/abstract-videos-model-query-builder'
+import { VideoModelBuilder } from './shared/video-model-builder'
import { BuildVideosListQueryOptions, VideosIdListQueryBuilder } from './videos-id-list-query-builder'
+/**
+ *
+ * Build videos list SQL query and create video models
+ *
+ */
+
export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder {
protected attributes: { [key: string]: string }
- protected joins: string[] = []
private innerQuery: string
private innerSort: string
+ private readonly videoModelBuilder: VideoModelBuilder
+
constructor (protected readonly sequelize: Sequelize) {
super('list')
+
+ this.videoModelBuilder = new VideoModelBuilder(this.mode, this.tables)
}
queryVideos (options: BuildVideosListQueryOptions) {
this.buildInnerQuery(options)
this.buildListQueryFromIdsQuery(options)
- return this.runQuery(undefined, true).then(rows => this.videoModelBuilder.buildVideosFromRows(rows))
+ return this.runQuery()
+ .then(rows => this.videoModelBuilder.buildVideosFromRows(rows))
}
private buildInnerQuery (options: BuildVideosListQueryOptions) {
'"video".*': ''
}
- this.joins = [ 'INNER JOIN "video" ON "tmp"."id" = "video"."id"' ]
+ this.addJoin('INNER JOIN "video" ON "tmp"."id" = "video"."id"')
this.includeChannels()
this.includeAccounts()
this.includeThumbnails()
if (options.withFiles) {
- this.includeFiles()
+ this.includeWebtorrentFiles(false)
+ this.includeStreamingPlaylistFiles(false)
}
if (options.user) {
const select = this.buildSelect()
- this.query = `${select} FROM (${this.innerQuery}) AS "tmp" ${this.joins.join(' ')} ${this.innerSort}`
+ this.query = `${select} FROM (${this.innerQuery}) AS "tmp" ${this.joins} ${this.innerSort}`
}
}