aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/job.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 09:45:46 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 09:45:46 +0200
commit74889a71fe687dda74f2a687653122327807af36 (patch)
treee938e8b6401b74fbec80513a877d9967f2c0dbcd /server/models/job.ts
parent15a302943d84bc0978b84fe33110c4daa451d311 (diff)
downloadPeerTube-74889a71fe687dda74f2a687653122327807af36.tar.gz
PeerTube-74889a71fe687dda74f2a687653122327807af36.tar.zst
PeerTube-74889a71fe687dda74f2a687653122327807af36.zip
Reorganize model files
Diffstat (limited to 'server/models/job.ts')
-rw-r--r--server/models/job.ts63
1 files changed, 0 insertions, 63 deletions
diff --git a/server/models/job.ts b/server/models/job.ts
deleted file mode 100644
index d4380a575..000000000
--- a/server/models/job.ts
+++ /dev/null
@@ -1,63 +0,0 @@
1import { values } from 'lodash'
2import * as Sequelize from 'sequelize'
3
4import { JOB_STATES } from '../initializers'
5
6import { addMethodsToModel } from './utils'
7import {
8 JobClass,
9 JobInstance,
10 JobAttributes,
11
12 JobMethods
13} from './job-interface'
14
15let Job: Sequelize.Model<JobInstance, JobAttributes>
16let listWithLimit: JobMethods.ListWithLimit
17
18export default function defineJob (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
19 Job = sequelize.define<JobInstance, JobAttributes>('Job',
20 {
21 state: {
22 type: DataTypes.ENUM(values(JOB_STATES)),
23 allowNull: false
24 },
25 handlerName: {
26 type: DataTypes.STRING,
27 allowNull: false
28 },
29 handlerInputData: {
30 type: DataTypes.JSON,
31 allowNull: true
32 }
33 },
34 {
35 indexes: [
36 {
37 fields: [ 'state' ]
38 }
39 ]
40 }
41 )
42
43 const classMethods = [ listWithLimit ]
44 addMethodsToModel(Job, classMethods)
45
46 return Job
47}
48
49// ---------------------------------------------------------------------------
50
51listWithLimit = function (limit: number, state: string, callback: JobMethods.ListWithLimitCallback) {
52 const query = {
53 order: [
54 [ 'id', 'ASC' ]
55 ],
56 limit: limit,
57 where: {
58 state
59 }
60 }
61
62 return Job.findAll(query).asCallback(callback)
63}