214 lines
2.4 KiB
JavaScript
214 lines
2.4 KiB
JavaScript
const config = require('../../config');
|
|
const providers = config.providers;
|
|
const crypto = require('crypto');
|
|
const bcrypt = require('bcrypt');
|
|
const moment = require('moment');
|
|
|
|
module.exports = function(sequelize, DataTypes) {
|
|
const render_jobs = sequelize.define(
|
|
'render_jobs',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
job_type: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"transcribe",
|
|
|
|
|
|
"moment_detection",
|
|
|
|
|
|
"hook_generation",
|
|
|
|
|
|
"caption_generation",
|
|
|
|
|
|
"render_clip",
|
|
|
|
|
|
"thumbnail_generation"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
status: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"queued",
|
|
|
|
|
|
"running",
|
|
|
|
|
|
"succeeded",
|
|
|
|
|
|
"failed",
|
|
|
|
|
|
"canceled"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
attempts: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
priority: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
worker_key: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
input_payload: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
output_payload: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
error_message: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
queued_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
started_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
finished_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
render_jobs.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
db.render_jobs.belongsTo(db.workspaces, {
|
|
as: 'workspace',
|
|
foreignKey: {
|
|
name: 'workspaceId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.render_jobs.belongsTo(db.videos, {
|
|
as: 'video',
|
|
foreignKey: {
|
|
name: 'videoId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.render_jobs.belongsTo(db.clips, {
|
|
as: 'clip',
|
|
foreignKey: {
|
|
name: 'clipId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.render_jobs.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.render_jobs.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return render_jobs;
|
|
};
|
|
|
|
|