aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-18 15:22:36 +0100
committerChocobozzz <me@florianbigard.com>2018-01-18 16:43:26 +0100
commit2c897999fe877c52c8f7458d8bbff6c9367b6587 (patch)
tree3f66304fcea68a608bfd0f800e991731d910cc3d /server/models/video/video.ts
parent54e740594bc2eacd8026b5d2d6cfdfc06416a65b (diff)
downloadPeerTube-2c897999fe877c52c8f7458d8bbff6c9367b6587.tar.gz
PeerTube-2c897999fe877c52c8f7458d8bbff6c9367b6587.tar.zst
PeerTube-2c897999fe877c52c8f7458d8bbff6c9367b6587.zip
Optimize SQL query that fetch actor outbox
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts54
1 files changed, 46 insertions, 8 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 0d115367f..7af68b20b 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -459,7 +459,8 @@ export class VideoModel extends Model<VideoModel> {
459 }, 459 },
460 include: [ 460 include: [
461 { 461 {
462 model: VideoShareModel, 462 attributes: [ 'id' ],
463 model: VideoShareModel.unscoped(),
463 required: false, 464 required: false,
464 where: { 465 where: {
465 [Sequelize.Op.and]: [ 466 [Sequelize.Op.and]: [
@@ -475,28 +476,65 @@ export class VideoModel extends Model<VideoModel> {
475 }, 476 },
476 include: [ 477 include: [
477 { 478 {
478 model: ActorModel, 479 attributes: [ 'id', 'url' ],
479 required: true 480 model: ActorModel.unscoped()
480 } 481 }
481 ] 482 ]
482 }, 483 },
483 { 484 {
484 model: VideoChannelModel, 485 model: VideoChannelModel.unscoped(),
485 required: true, 486 required: true,
486 include: [ 487 include: [
487 { 488 {
488 model: AccountModel, 489 attributes: [ 'name' ],
490 model: AccountModel.unscoped(),
491 required: true,
492 include: [
493 {
494 attributes: [ 'id', 'url' ],
495 model: ActorModel.unscoped(),
496 required: true
497 }
498 ]
499 },
500 {
501 attributes: [ 'id', 'url' ],
502 model: ActorModel.unscoped(),
489 required: true 503 required: true
490 } 504 }
491 ] 505 ]
492 }, 506 },
493 { 507 {
508 attributes: [ 'type' ],
494 model: AccountVideoRateModel, 509 model: AccountVideoRateModel,
495 include: [ AccountModel ] 510 required: false,
511 include: [
512 {
513 attributes: [ 'id' ],
514 model: AccountModel.unscoped(),
515 include: [
516 {
517 attributes: [ 'url' ],
518 model: ActorModel.unscoped(),
519 include: [
520 {
521 attributes: [ 'host' ],
522 model: ServerModel,
523 required: false
524 }
525 ]
526 }
527 ]
528 }
529 ]
530 },
531 {
532 attributes: [ 'url' ],
533 model: VideoCommentModel,
534 required: false
496 }, 535 },
497 VideoFileModel, 536 VideoFileModel,
498 TagModel, 537 TagModel
499 VideoCommentModel
500 ] 538 ]
501 } 539 }
502 540