Improve prune script

This commit is contained in:
Chocobozzz
2018-09-28 10:56:13 +02:00
parent 07524e229f
commit 5ce1208a0a
2 changed files with 60 additions and 9 deletions

View File

@@ -146,6 +146,38 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
return VideoRedundancyModel.findOne(query)
}
static async isLocalByVideoUUIDExists (uuid: string) {
const actor = await getServerActor()
const query = {
raw: true,
attributes: [ 'id' ],
where: {
actorId: actor.id
},
include: [
{
attributes: [ ],
model: VideoFileModel,
required: true,
include: [
{
attributes: [ ],
model: VideoModel,
required: true,
where: {
uuid
}
}
]
}
]
}
return VideoRedundancyModel.findOne(query)
.then(r => !!r)
}
static async getVideoSample (p: Bluebird<VideoModel[]>) {
const rows = await p
const ids = rows.map(r => r.id)