aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-03-11 14:39:28 +0100
committerChocobozzz <me@florianbigard.com>2020-03-11 15:02:20 +0100
commit764a965778ac89e027fd05dd35697c6763e0dc18 (patch)
treeecc18834566b940c729a57b5bf0d088e894f03d3 /shared
parentfab6746354f9d9cb65c35d8bd9352c4b773b4c69 (diff)
downloadPeerTube-764a965778ac89e027fd05dd35697c6763e0dc18.tar.gz
PeerTube-764a965778ac89e027fd05dd35697c6763e0dc18.tar.zst
PeerTube-764a965778ac89e027fd05dd35697c6763e0dc18.zip
Implement pagination for overviews endpoint
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/overviews/overviews.ts27
-rw-r--r--shared/models/overviews/videos-overview.ts30
2 files changed, 39 insertions, 18 deletions
diff --git a/shared/extra-utils/overviews/overviews.ts b/shared/extra-utils/overviews/overviews.ts
index 23e3ceb1e..ae4d31aa3 100644
--- a/shared/extra-utils/overviews/overviews.ts
+++ b/shared/extra-utils/overviews/overviews.ts
@@ -1,18 +1,33 @@
1import { makeGetRequest } from '../requests/requests' 1import { makeGetRequest } from '../requests/requests'
2 2
3function getVideosOverview (url: string, useCache = false) { 3function getVideosOverview (url: string, page: number, statusCodeExpected = 200) {
4 const path = '/api/v1/overviews/videos' 4 const path = '/api/v1/overviews/videos'
5 5
6 const query = { 6 const query = { page }
7 t: useCache ? undefined : new Date().getTime()
8 }
9 7
10 return makeGetRequest({ 8 return makeGetRequest({
11 url, 9 url,
12 path, 10 path,
13 query, 11 query,
14 statusCodeExpected: 200 12 statusCodeExpected
15 }) 13 })
16} 14}
17 15
18export { getVideosOverview } 16function getVideosOverviewWithToken (url: string, page: number, token: string, statusCodeExpected = 200) {
17 const path = '/api/v1/overviews/videos'
18
19 const query = { page }
20
21 return makeGetRequest({
22 url,
23 path,
24 query,
25 token,
26 statusCodeExpected
27 })
28}
29
30export {
31 getVideosOverview,
32 getVideosOverviewWithToken
33}
diff --git a/shared/models/overviews/videos-overview.ts b/shared/models/overviews/videos-overview.ts
index e725f166b..0f3cb4a52 100644
--- a/shared/models/overviews/videos-overview.ts
+++ b/shared/models/overviews/videos-overview.ts
@@ -1,18 +1,24 @@
1import { Video, VideoChannelSummary, VideoConstant } from '../videos' 1import { Video, VideoChannelSummary, VideoConstant } from '../videos'
2 2
3export interface ChannelOverview {
4 channel: VideoChannelSummary
5 videos: Video[]
6}
7
8export interface CategoryOverview {
9 category: VideoConstant<number>
10 videos: Video[]
11}
12
13export interface TagOverview {
14 tag: string
15 videos: Video[]
16}
17
3export interface VideosOverview { 18export interface VideosOverview {
4 channels: { 19 channels: ChannelOverview[]
5 channel: VideoChannelSummary
6 videos: Video[]
7 }[]
8 20
9 categories: { 21 categories: CategoryOverview[]
10 category: VideoConstant<number>
11 videos: Video[]
12 }[]
13 22
14 tags: { 23 tags: TagOverview[]
15 tag: string
16 videos: Video[]
17 }[]
18} 24}