})
Video: VideoModel
- static load (actorId: number, videoId: number, t: Sequelize.Transaction) {
+ static load (actorId: number, videoId: number, t?: Sequelize.Transaction) {
return VideoShareModel.scope(ScopeNames.WITH_ACTOR).findOne({
where: {
actorId,
.then(res => res.map(r => r.Actor))
}
- static loadActorsByVideoOwner (actorOwnerId: number, t: Sequelize.Transaction): Bluebird<ActorModel[]> {
+ static loadActorsWhoSharedVideosOf (actorOwnerId: number, t: Sequelize.Transaction): Bluebird<ActorModel[]> {
const query = {
attributes: [],
include: [
return VideoShareModel.findAndCountAll(query)
}
+
+ static cleanOldSharesOf (videoId: number, beforeUpdatedAt: Date) {
+ const query = {
+ where: {
+ updatedAt: {
+ [Sequelize.Op.lt]: beforeUpdatedAt
+ },
+ videoId
+ }
+ }
+
+ return VideoShareModel.destroy(query)
+ }
}