import { VIDEO_RATE_TYPES } from '../../initializers'
import { VideoModel } from '../video/video'
import { AccountModel } from './account'
+import { ActorModel } from '../activitypub/actor'
/*
Account rates per video.
{
fields: [ 'videoId', 'accountId' ],
unique: true
+ },
+ {
+ fields: [ 'videoId' ]
+ },
+ {
+ fields: [ 'accountId' ]
+ },
+ {
+ fields: [ 'videoId', 'type' ]
}
]
})
return AccountVideoRateModel.findOne(options)
}
+
+ static listAndCountAccountUrlsByVideoId (rateType: VideoRateType, videoId: number, start: number, count: number, t?: Transaction) {
+ const query = {
+ offset: start,
+ limit: count,
+ where: {
+ videoId,
+ type: rateType
+ },
+ transaction: t,
+ include: [
+ {
+ attributes: [ 'actorId' ],
+ model: AccountModel.unscoped(),
+ required: true,
+ include: [
+ {
+ attributes: [ 'url' ],
+ model: ActorModel.unscoped(),
+ required: true
+ }
+ ]
+ }
+ ]
+ }
+
+ return AccountVideoRateModel.findAndCountAll(query)
+ }
}