aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/server/jobs.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-12-14 12:00:35 +0100
committerChocobozzz <me@florianbigard.com>2020-12-14 12:00:35 +0100
commit402145b8630d1908c35f8c22846ddc4475f25d3e (patch)
treeff50cb09c5f56cc408ef20a7c959ef7a0642b76b /shared/extra-utils/server/jobs.ts
parentc04816108e8ec62eb29caf82806f3927dc5eb85a (diff)
downloadPeerTube-402145b8630d1908c35f8c22846ddc4475f25d3e.tar.gz
PeerTube-402145b8630d1908c35f8c22846ddc4475f25d3e.tar.zst
PeerTube-402145b8630d1908c35f8c22846ddc4475f25d3e.zip
Refactor jobs state
Diffstat (limited to 'shared/extra-utils/server/jobs.ts')
-rw-r--r--shared/extra-utils/server/jobs.ts20
1 files changed, 14 insertions, 6 deletions
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts
index cac00e9ab..a53749589 100644
--- a/shared/extra-utils/server/jobs.ts
+++ b/shared/extra-utils/server/jobs.ts
@@ -1,12 +1,20 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3import { makeGetRequest } from '../../../shared/extra-utils'
2import { Job, JobState, JobType } from '../../models' 4import { Job, JobState, JobType } from '../../models'
3import { wait } from '../miscs/miscs' 5import { wait } from '../miscs/miscs'
4import { ServerInfo } from './servers' 6import { ServerInfo } from './servers'
5import { makeGetRequest } from '../../../shared/extra-utils'
6import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
7 7
8function getJobsList (url: string, accessToken: string, state: JobState) { 8function buildJobsUrl (state?: JobState) {
9 const path = '/api/v1/jobs/' + state 9 let path = '/api/v1/jobs'
10
11 if (state) path += '/' + state
12
13 return path
14}
15
16function getJobsList (url: string, accessToken: string, state?: JobState) {
17 const path = buildJobsUrl(state)
10 18
11 return request(url) 19 return request(url)
12 .get(path) 20 .get(path)
@@ -19,14 +27,14 @@ function getJobsList (url: string, accessToken: string, state: JobState) {
19function getJobsListPaginationAndSort (options: { 27function getJobsListPaginationAndSort (options: {
20 url: string 28 url: string
21 accessToken: string 29 accessToken: string
22 state: JobState
23 start: number 30 start: number
24 count: number 31 count: number
25 sort: string 32 sort: string
33 state?: JobState
26 jobType?: JobType 34 jobType?: JobType
27}) { 35}) {
28 const { url, accessToken, state, start, count, sort, jobType } = options 36 const { url, accessToken, state, start, count, sort, jobType } = options
29 const path = '/api/v1/jobs/' + state 37 const path = buildJobsUrl(state)
30 38
31 const query = { 39 const query = {
32 start, 40 start,