+ static loadAndPopulateVideo (id: number): Bluebird<MVideoImportDefault> {
+ return VideoImportModel.findByPk(id)
+ }
+
+ static listUserVideoImportsForApi (userId: number, start: number, count: number, sort: string) {
+ const query = {
+ distinct: true,
+ include: [
+ {
+ attributes: [ 'id' ],
+ model: UserModel.unscoped(), // FIXME: Without this, sequelize try to COUNT(DISTINCT(*)) which is an invalid SQL query
+ required: true
+ }
+ ],
+ offset: start,
+ limit: count,
+ order: getSort(sort),
+ where: {
+ userId
+ }
+ }
+
+ return VideoImportModel.findAndCountAll<MVideoImportDefault>(query)
+ .then(({ rows, count }) => {
+ return {
+ data: rows,
+ total: count
+ }
+ })
+ }
+
+ getTargetIdentifier () {
+ return this.targetUrl || this.magnetUri || this.torrentName
+ }
+
+ toFormattedJSON (this: MVideoImportFormattable): VideoImport {