aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-25 16:21:16 +0200
committerChocobozzz <me@florianbigard.com>2018-05-25 16:21:16 +0200
commit8fffe21a7bc96d08b229293d66ddba576e609790 (patch)
tree5ebd5f5198a59084c5338ce197d7e836b39200a4 /server/models/account
parente251f170b00b2014ac4e823113c6ff40e3fb1471 (diff)
downloadPeerTube-8fffe21a7bc96d08b229293d66ddba576e609790.tar.gz
PeerTube-8fffe21a7bc96d08b229293d66ddba576e609790.tar.zst
PeerTube-8fffe21a7bc96d08b229293d66ddba576e609790.zip
Refractor and optimize AP collections
Only display urls in general object, and paginate video comments, shares, likes and dislikes
Diffstat (limited to 'server/models/account')
-rw-r--r--server/models/account/account-video-rate.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts
index e969e4a43..508ab814f 100644
--- a/server/models/account/account-video-rate.ts
+++ b/server/models/account/account-video-rate.ts
@@ -6,6 +6,7 @@ import { VideoRateType } from '../../../shared/models/videos'
6import { VIDEO_RATE_TYPES } from '../../initializers' 6import { VIDEO_RATE_TYPES } from '../../initializers'
7import { VideoModel } from '../video/video' 7import { VideoModel } from '../video/video'
8import { AccountModel } from './account' 8import { AccountModel } from './account'
9import { ActorModel } from '../activitypub/actor'
9 10
10/* 11/*
11 Account rates per video. 12 Account rates per video.
@@ -66,4 +67,32 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
66 67
67 return AccountVideoRateModel.findOne(options) 68 return AccountVideoRateModel.findOne(options)
68 } 69 }
70
71 static listAndCountAccountUrlsByVideoId (rateType: VideoRateType, videoId: number, start: number, count: number, t?: Transaction) {
72 const query = {
73 start,
74 count,
75 where: {
76 videoId,
77 type: rateType
78 },
79 transaction: t,
80 include: [
81 {
82 attributes: [ 'actorId' ],
83 model: AccountModel.unscoped(),
84 required: true,
85 include: [
86 {
87 attributes: [ 'url' ],
88 model: ActorModel.unscoped(),
89 required: true
90 }
91 ]
92 }
93 ]
94 }
95
96 return AccountVideoRateModel.findAndCountAll(query)
97 }
69} 98}