aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-01 19:09:55 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-01 19:24:37 +0200
commit15d4ee04a94230e1ea83c2959a1981105699ba22 (patch)
tree9905fb9d2385eca700d6c906ee6ec750eaba85b3 /server/models/video.js
parent843aa7ba0312e7180e7bbae147e32ee60e70d9ba (diff)
downloadPeerTube-15d4ee04a94230e1ea83c2959a1981105699ba22.tar.gz
PeerTube-15d4ee04a94230e1ea83c2959a1981105699ba22.tar.zst
PeerTube-15d4ee04a94230e1ea83c2959a1981105699ba22.zip
Server: little refractoring when listing videos
Diffstat (limited to 'server/models/video.js')
-rw-r--r--server/models/video.js22
1 files changed, 12 insertions, 10 deletions
diff --git a/server/models/video.js b/server/models/video.js
index 0eef4114c..029cb6d7c 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -544,11 +544,7 @@ function listForApi (start, count, sort, callback) {
544 544
545 this.sequelize.models.Tag 545 this.sequelize.models.Tag
546 ], 546 ],
547 where: { 547 where: createBaseVideosWhere.call(this)
548 id: { $notIn: this.sequelize.literal(
549 '(SELECT "BlacklistedVideos"."videoId" FROM "BlacklistedVideos")'
550 )}
551 }
552 } 548 }
553 549
554 return this.findAndCountAll(query).asCallback(function (err, result) { 550 return this.findAndCountAll(query).asCallback(function (err, result) {
@@ -656,11 +652,7 @@ function searchAndPopulateAuthorAndPodAndTags (value, field, start, count, sort,
656 } 652 }
657 653
658 const query = { 654 const query = {
659 where: { 655 where: createBaseVideosWhere.call(this),
660 id: { $notIn: this.sequelize.literal(
661 '(SELECT "BlacklistedVideos"."videoId" FROM "BlacklistedVideos")'
662 )}
663 },
664 offset: start, 656 offset: start,
665 limit: count, 657 limit: count,
666 distinct: true, // For the count, a video can have many tags 658 distinct: true, // For the count, a video can have many tags
@@ -715,6 +707,16 @@ function searchAndPopulateAuthorAndPodAndTags (value, field, start, count, sort,
715 707
716// --------------------------------------------------------------------------- 708// ---------------------------------------------------------------------------
717 709
710function createBaseVideosWhere () {
711 return {
712 id: {
713 $notIn: this.sequelize.literal(
714 '(SELECT "BlacklistedVideos"."videoId" FROM "BlacklistedVideos")'
715 )
716 }
717 }
718}
719
718function removeThumbnail (video, callback) { 720function removeThumbnail (video, callback) {
719 const thumbnailPath = pathUtils.join(constants.CONFIG.STORAGE.THUMBNAILS_DIR, video.getThumbnailName()) 721 const thumbnailPath = pathUtils.join(constants.CONFIG.STORAGE.THUMBNAILS_DIR, video.getThumbnailName())
720 fs.unlink(thumbnailPath, callback) 722 fs.unlink(thumbnailPath, callback)