- static listForApi (start: number, count: number, sort: SortType) {
- const query = {
- offset: start,
- limit: count,
- order: getSortOnModel(sort.sortModel, sort.sortValue),
- include: [
- {
- model: VideoModel,
- required: true
- }
- ]
+ static listForApi (start: number, count: number, sort: SortType, type?: VideoBlacklistType) {
+ function buildBaseQuery (): FindOptions {
+ return {
+ offset: start,
+ limit: count,
+ order: getSortOnModel(sort.sortModel, sort.sortValue)
+ }
+ }
+
+ const countQuery = buildBaseQuery()
+
+ const findQuery = buildBaseQuery()
+ findQuery.subQuery = false
+ findQuery.include = [
+ {
+ model: VideoModel,
+ required: true,
+ include: [
+ {
+ model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } as SummaryOptions ] }),
+ required: true
+ },
+ {
+ model: ThumbnailModel,
+ attributes: [ 'type', 'filename' ],
+ required: false
+ }
+ ]
+ }
+ ]
+
+ if (type) {
+ countQuery.where = { type }
+ findQuery.where = { type }