followerActorId: number
includeLocalVideos: boolean
+ withoutId?: boolean
+
filter?: VideoFilter
categoryOneOf?: number[]
nsfw?: boolean
{
model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, true ] }),
required: true
+ },
+ {
+ attributes: [ 'type', 'filename' ],
+ model: ThumbnailModel,
+ required: false
}
]
}
return query
},
[ ScopeNames.AVAILABLE_FOR_LIST_IDS ]: (options: AvailableForListIDsOptions) => {
+ const attributes = options.withoutId === true ? [] : [ 'id' ]
+
const query: FindOptions = {
raw: true,
- attributes: [ 'id' ],
+ attributes,
where: {
id: {
[ Op.and ]: [
const countQuery = buildBaseQuery()
const findQuery = buildBaseQuery()
- findQuery.include.push({
- model: ScheduleVideoUpdateModel,
- required: false
- })
-
- findQuery.include.push({
- model: VideoBlacklistModel,
- required: false
- })
+ const findScopes = [
+ ScopeNames.WITH_SCHEDULED_UPDATE,
+ ScopeNames.WITH_BLACKLISTED,
+ ScopeNames.WITH_THUMBNAILS
+ ]
if (withFiles === true) {
findQuery.include.push({
return Promise.all([
VideoModel.count(countQuery),
- VideoModel.findAll(findQuery)
+ VideoModel.scope(findScopes).findAll(findQuery)
]).then(([ count, rows ]) => {
return {
data: rows,
const scopeOptions: AvailableForListIDsOptions = {
serverAccountId: serverActor.Account.id,
followerActorId,
- includeLocalVideos: true
+ includeLocalVideos: true,
+ withoutId: true // Don't break aggregation
}
const query: FindOptions = {
]
}
- const apiScope: (string | ScopeOptions)[] = [ ScopeNames.WITH_THUMBNAILS ]
+ const apiScope: (string | ScopeOptions)[] = []
if (options.user) {
apiScope.push({ method: [ ScopeNames.WITH_USER_HISTORY, options.user.id ] })