Server: little refractoring when listing videos
This commit is contained in:
parent
843aa7ba03
commit
15d4ee04a9
|
@ -544,11 +544,7 @@ function listForApi (start, count, sort, callback) {
|
||||||
|
|
||||||
this.sequelize.models.Tag
|
this.sequelize.models.Tag
|
||||||
],
|
],
|
||||||
where: {
|
where: createBaseVideosWhere.call(this)
|
||||||
id: { $notIn: this.sequelize.literal(
|
|
||||||
'(SELECT "BlacklistedVideos"."videoId" FROM "BlacklistedVideos")'
|
|
||||||
)}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.findAndCountAll(query).asCallback(function (err, result) {
|
return this.findAndCountAll(query).asCallback(function (err, result) {
|
||||||
|
@ -656,11 +652,7 @@ function searchAndPopulateAuthorAndPodAndTags (value, field, start, count, sort,
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
where: {
|
where: createBaseVideosWhere.call(this),
|
||||||
id: { $notIn: this.sequelize.literal(
|
|
||||||
'(SELECT "BlacklistedVideos"."videoId" FROM "BlacklistedVideos")'
|
|
||||||
)}
|
|
||||||
},
|
|
||||||
offset: start,
|
offset: start,
|
||||||
limit: count,
|
limit: count,
|
||||||
distinct: true, // For the count, a video can have many tags
|
distinct: true, // For the count, a video can have many tags
|
||||||
|
@ -715,6 +707,16 @@ function searchAndPopulateAuthorAndPodAndTags (value, field, start, count, sort,
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function createBaseVideosWhere () {
|
||||||
|
return {
|
||||||
|
id: {
|
||||||
|
$notIn: this.sequelize.literal(
|
||||||
|
'(SELECT "BlacklistedVideos"."videoId" FROM "BlacklistedVideos")'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function removeThumbnail (video, callback) {
|
function removeThumbnail (video, callback) {
|
||||||
const thumbnailPath = pathUtils.join(constants.CONFIG.STORAGE.THUMBNAILS_DIR, video.getThumbnailName())
|
const thumbnailPath = pathUtils.join(constants.CONFIG.STORAGE.THUMBNAILS_DIR, video.getThumbnailName())
|
||||||
fs.unlink(thumbnailPath, callback)
|
fs.unlink(thumbnailPath, callback)
|
||||||
|
|
Loading…
Reference in New Issue