aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/job
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-25 15:05:18 +0100
committerChocobozzz <me@florianbigard.com>2018-01-25 18:41:17 +0100
commit94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4 (patch)
tree32a9148e0e4567f0c4ffae0412cbed20b84e8873 /server/models/job
parentd765fafc3faf0db9818eb1a07161df1cb1bc0efa (diff)
downloadPeerTube-94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4.tar.gz
PeerTube-94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4.tar.zst
PeerTube-94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4.zip
Move job queue to redis
We'll use it as cache in the future. /!\ You'll loose your old jobs (pending jobs too) so upgrade only when you don't have pending job anymore.
Diffstat (limited to 'server/models/job')
-rw-r--r--server/models/job/job.ts80
1 files changed, 0 insertions, 80 deletions
diff --git a/server/models/job/job.ts b/server/models/job/job.ts
deleted file mode 100644
index ba1c6737e..000000000
--- a/server/models/job/job.ts
+++ /dev/null
@@ -1,80 +0,0 @@
1import { values } from 'lodash'
2import { AllowNull, Column, CreatedAt, DataType, Model, Table, UpdatedAt } from 'sequelize-typescript'
3import { JobCategory, JobState } from '../../../shared/models'
4import { JOB_CATEGORIES, JOB_STATES } from '../../initializers'
5import { getSort } from '../utils'
6
7@Table({
8 tableName: 'job',
9 indexes: [
10 {
11 fields: [ 'state', 'category' ]
12 }
13 ]
14})
15export class JobModel extends Model<JobModel> {
16 @AllowNull(false)
17 @Column(DataType.ENUM(values(JOB_STATES)))
18 state: JobState
19
20 @AllowNull(false)
21 @Column(DataType.ENUM(values(JOB_CATEGORIES)))
22 category: JobCategory
23
24 @AllowNull(false)
25 @Column
26 handlerName: string
27
28 @AllowNull(true)
29 @Column(DataType.JSON)
30 handlerInputData: any
31
32 @CreatedAt
33 createdAt: Date
34
35 @UpdatedAt
36 updatedAt: Date
37
38 static listWithLimitByCategory (limit: number, state: JobState, jobCategory: JobCategory) {
39 const query = {
40 order: [
41 [ 'id', 'ASC' ]
42 ],
43 limit: limit,
44 where: {
45 state,
46 category: jobCategory
47 },
48 logging: false
49 }
50
51 return JobModel.findAll(query)
52 }
53
54 static listForApi (start: number, count: number, sort: string) {
55 const query = {
56 offset: start,
57 limit: count,
58 order: [ getSort(sort) ]
59 }
60
61 return JobModel.findAndCountAll(query).then(({ rows, count }) => {
62 return {
63 data: rows,
64 total: count
65 }
66 })
67 }
68
69 toFormattedJSON () {
70 return {
71 id: this.id,
72 state: this.state,
73 category: this.category,
74 handlerName: this.handlerName,
75 handlerInputData: this.handlerInputData,
76 createdAt: this.createdAt,
77 updatedAt: this.updatedAt
78 }
79 }
80}