accountId?: number
videoChannelId?: number
trendingDays?: number
- user?: UserModel
+ user?: UserModel,
+ historyOfUser?: UserModel
}
@Scopes({
query.subQuery = false
}
+ if (options.historyOfUser) {
+ query.include.push({
+ model: UserVideoHistoryModel,
+ required: true,
+ where: {
+ userId: options.historyOfUser.id
+ }
+ })
+ }
+
return query
},
[ ScopeNames.WITH_ACCOUNT_DETAILS ]: {
videoChannelId?: number,
followerActorId?: number
trendingDays?: number,
- user?: UserModel
+ user?: UserModel,
+ historyOfUser?: UserModel
}, countVideos = true) {
if (options.filter && options.filter === 'all-local' && !options.user.hasRight(UserRight.SEE_ALL_VIDEOS)) {
throw new Error('Try to filter all-local but no user has not the see all videos right')
videoChannelId: options.videoChannelId,
includeLocalVideos: options.includeLocalVideos,
user: options.user,
+ historyOfUser: options.historyOfUser,
trendingDays
}
}
const [ count, rowsId ] = await Promise.all([
- countVideos ? VideoModel.scope(countScope).count(countQuery) : Promise.resolve(undefined),
+ countVideos ? VideoModel.scope(countScope).count(countQuery) : Promise.resolve<number>(undefined),
VideoModel.scope(idsScope).findAll(query)
])
const ids = rowsId.map(r => r.id)