-import { Sequelize } from 'sequelize'
-import { BuildVideoGetQueryOptions } from '../video-model-get-query-builder'
+import { Sequelize, Transaction } from 'sequelize'
import { AbstractVideoQueryBuilder } from './abstract-video-query-builder'
+export type FileQueryOptions = {
+ id?: string | number
+ url?: string
+
+ includeRedundancy: boolean
+
+ transaction?: Transaction
+
+ logging?: boolean
+}
+
/**
*
* Fetch files (webtorrent and streaming playlist) according to a video
protected attributes: { [key: string]: string }
constructor (protected readonly sequelize: Sequelize) {
- super('get')
+ super(sequelize, 'get')
}
- queryWebTorrentVideos (options: BuildVideoGetQueryOptions) {
+ queryWebTorrentVideos (options: FileQueryOptions) {
this.buildWebtorrentFilesQuery(options)
return this.runQuery(options)
}
- queryStreamingPlaylistVideos (options: BuildVideoGetQueryOptions) {
+ queryStreamingPlaylistVideos (options: FileQueryOptions) {
this.buildVideoStreamingPlaylistFilesQuery(options)
return this.runQuery(options)
}
- private buildWebtorrentFilesQuery (options: BuildVideoGetQueryOptions) {
+ private buildWebtorrentFilesQuery (options: FileQueryOptions) {
this.attributes = {
'"video"."id"': ''
}
this.includeWebtorrentFiles()
- if (this.shouldIncludeRedundancies(options)) {
+ if (options.includeRedundancy) {
this.includeWebTorrentRedundancies()
}
this.query = this.buildQuery()
}
- private buildVideoStreamingPlaylistFilesQuery (options: BuildVideoGetQueryOptions) {
+ private buildVideoStreamingPlaylistFilesQuery (options: FileQueryOptions) {
this.attributes = {
'"video"."id"': ''
}
this.includeStreamingPlaylistFiles()
- if (this.shouldIncludeRedundancies(options)) {
+ if (options.includeRedundancy) {
this.includeStreamingPlaylistRedundancies()
}
private buildQuery () {
return `${this.buildSelect()} FROM "video" ${this.joins} ${this.where}`
}
-
- private shouldIncludeRedundancies (options: BuildVideoGetQueryOptions) {
- return options.type === 'api'
- }
}