aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-05-10 10:52:52 +0200
committerChocobozzz <me@florianbigard.com>2021-05-10 13:56:16 +0200
commit649e812947b1afa1f025f2f3dc833a8cfb772e9c (patch)
treea99c1d8bf4142f4e6cb01ed6778f80eab0fafa14 /server
parentfd5586b33748ecdef1d46af2a7d540ba8c8e55df (diff)
downloadPeerTube-649e812947b1afa1f025f2f3dc833a8cfb772e9c.tar.gz
PeerTube-649e812947b1afa1f025f2f3dc833a8cfb772e9c.tar.zst
PeerTube-649e812947b1afa1f025f2f3dc833a8cfb772e9c.zip
Optimize videos feed endpoint
Diffstat (limited to 'server')
-rw-r--r--server/controllers/feeds.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts
index 921067e65..f0717bbbc 100644
--- a/server/controllers/feeds.ts
+++ b/server/controllers/feeds.ts
@@ -167,7 +167,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
167 videoChannelId: videoChannel ? videoChannel.id : null 167 videoChannelId: videoChannel ? videoChannel.id : null
168 } 168 }
169 169
170 const resultList = await VideoModel.listForApi({ 170 const { data } = await VideoModel.listForApi({
171 start, 171 start,
172 count: FEEDS.COUNT, 172 count: FEEDS.COUNT,
173 sort: req.query.sort, 173 sort: req.query.sort,
@@ -175,10 +175,11 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
175 nsfw, 175 nsfw,
176 filter: req.query.filter as VideoFilter, 176 filter: req.query.filter as VideoFilter,
177 withFiles: true, 177 withFiles: true,
178 countVideos: false,
178 ...options 179 ...options
179 }) 180 })
180 181
181 addVideosToFeed(feed, resultList.data) 182 addVideosToFeed(feed, data)
182 183
183 // Now the feed generation is done, let's send it! 184 // Now the feed generation is done, let's send it!
184 return sendFeed(feed, req, res) 185 return sendFeed(feed, req, res)
@@ -198,20 +199,22 @@ async function generateVideoFeedForSubscriptions (req: express.Request, res: exp
198 queryString: new URL(WEBSERVER.URL + req.url).search 199 queryString: new URL(WEBSERVER.URL + req.url).search
199 }) 200 })
200 201
201 const resultList = await VideoModel.listForApi({ 202 const { data } = await VideoModel.listForApi({
202 start, 203 start,
203 count: FEEDS.COUNT, 204 count: FEEDS.COUNT,
204 sort: req.query.sort, 205 sort: req.query.sort,
205 includeLocalVideos: false, 206 includeLocalVideos: false,
206 nsfw, 207 nsfw,
207 filter: req.query.filter as VideoFilter, 208 filter: req.query.filter as VideoFilter,
209
208 withFiles: true, 210 withFiles: true,
211 countVideos: false,
209 212
210 followerActorId: res.locals.user.Account.Actor.id, 213 followerActorId: res.locals.user.Account.Actor.id,
211 user: res.locals.user 214 user: res.locals.user
212 }) 215 })
213 216
214 addVideosToFeed(feed, resultList.data) 217 addVideosToFeed(feed, data)
215 218
216 // Now the feed generation is done, let's send it! 219 // Now the feed generation is done, let's send it!
217 return sendFeed(feed, req, res) 220 return sendFeed(feed, req, res)