aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/overviews.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-14 14:57:59 +0200
committerChocobozzz <me@florianbigard.com>2018-09-14 14:57:59 +0200
commit4b5384f6e7be62d072d21d8d964951ba572ab10e (patch)
tree64dbd0c55096435ef804988c4750f717ad140633 /server/controllers/api/overviews.ts
parentcfc16a6db88378f83fa3a501170fa0fc5e7d6636 (diff)
downloadPeerTube-4b5384f6e7be62d072d21d8d964951ba572ab10e.tar.gz
PeerTube-4b5384f6e7be62d072d21d8d964951ba572ab10e.tar.zst
PeerTube-4b5384f6e7be62d072d21d8d964951ba572ab10e.zip
Add redundancy stats
Diffstat (limited to 'server/controllers/api/overviews.ts')
-rw-r--r--server/controllers/api/overviews.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts
index cc3cc54a7..8b6773056 100644
--- a/server/controllers/api/overviews.ts
+++ b/server/controllers/api/overviews.ts
@@ -21,6 +21,16 @@ export { overviewsRouter }
21 21
22// --------------------------------------------------------------------------- 22// ---------------------------------------------------------------------------
23 23
24const buildSamples = memoizee(async function () {
25 const [ categories, channels, tags ] = await Promise.all([
26 VideoModel.getRandomFieldSamples('category', OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD, OVERVIEWS.VIDEOS.SAMPLES_COUNT),
27 VideoModel.getRandomFieldSamples('channelId', OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD ,OVERVIEWS.VIDEOS.SAMPLES_COUNT),
28 TagModel.getRandomSamples(OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD, OVERVIEWS.VIDEOS.SAMPLES_COUNT)
29 ])
30
31 return { categories, channels, tags }
32}, { maxAge: MEMOIZE_TTL.OVERVIEWS_SAMPLE })
33
24// This endpoint could be quite long, but we cache it 34// This endpoint could be quite long, but we cache it
25async function getVideosOverview (req: express.Request, res: express.Response) { 35async function getVideosOverview (req: express.Request, res: express.Response) {
26 const attributes = await buildSamples() 36 const attributes = await buildSamples()
@@ -45,16 +55,6 @@ async function getVideosOverview (req: express.Request, res: express.Response) {
45 return res.json(result) 55 return res.json(result)
46} 56}
47 57
48const buildSamples = memoizee(async function () {
49 const [ categories, channels, tags ] = await Promise.all([
50 VideoModel.getRandomFieldSamples('category', OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD, OVERVIEWS.VIDEOS.SAMPLES_COUNT),
51 VideoModel.getRandomFieldSamples('channelId', OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD ,OVERVIEWS.VIDEOS.SAMPLES_COUNT),
52 TagModel.getRandomSamples(OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD, OVERVIEWS.VIDEOS.SAMPLES_COUNT)
53 ])
54
55 return { categories, channels, tags }
56}, { maxAge: MEMOIZE_TTL.OVERVIEWS_SAMPLE })
57
58async function getVideosByTag (tag: string, res: express.Response) { 58async function getVideosByTag (tag: string, res: express.Response) {
59 const videos = await getVideos(res, { tagsOneOf: [ tag ] }) 59 const videos = await getVideos(res, { tagsOneOf: [ tag ] })
60 60