aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-import.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-import.ts')
-rw-r--r--server/models/video/video-import.ts20
1 files changed, 16 insertions, 4 deletions
diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts
index c5c1a10f4..5d2b230e8 100644
--- a/server/models/video/video-import.ts
+++ b/server/models/video/video-import.ts
@@ -1,3 +1,4 @@
1import { WhereOptions } from 'sequelize'
1import { 2import {
2 AfterUpdate, 3 AfterUpdate,
3 AllowNull, 4 AllowNull,
@@ -125,7 +126,20 @@ export class VideoImportModel extends Model<Partial<AttributesOnly<VideoImportMo
125 return VideoImportModel.findByPk(id) 126 return VideoImportModel.findByPk(id)
126 } 127 }
127 128
128 static listUserVideoImportsForApi (userId: number, start: number, count: number, sort: string) { 129 static listUserVideoImportsForApi (options: {
130 userId: number
131 start: number
132 count: number
133 sort: string
134
135 targetUrl?: string
136 }) {
137 const { userId, start, count, sort, targetUrl } = options
138
139 const where: WhereOptions = { userId }
140
141 if (targetUrl) where['targetUrl'] = targetUrl
142
129 const query = { 143 const query = {
130 distinct: true, 144 distinct: true,
131 include: [ 145 include: [
@@ -138,9 +152,7 @@ export class VideoImportModel extends Model<Partial<AttributesOnly<VideoImportMo
138 offset: start, 152 offset: start,
139 limit: count, 153 limit: count,
140 order: getSort(sort), 154 order: getSort(sort),
141 where: { 155 where
142 userId
143 }
144 } 156 }
145 157
146 return VideoImportModel.findAndCountAll<MVideoImportDefault>(query) 158 return VideoImportModel.findAndCountAll<MVideoImportDefault>(query)