feat: match run model to run format

This commit is contained in:
karishmas6
2024-10-09 14:43:48 +05:30
parent 6e2529bb49
commit 29d90ec582

View File

@@ -2,34 +2,42 @@ import { Model, DataTypes, Optional } from 'sequelize';
import sequelize from '../db/config'; import sequelize from '../db/config';
import Robot from './Robot'; import Robot from './Robot';
interface InterpreterSettings {
maxConcurrency: number;
maxRepeats: number;
debug: boolean;
}
interface RunAttributes { interface RunAttributes {
id: string; id: string;
robotId: string;
status: string; status: string;
name: string; name: string;
startedAt: Date; robotId: string;
finishedAt: Date; startedAt: string;
finishedAt: string;
browserId: string; browserId: string;
interpreterSettings: object; interpreterSettings: InterpreterSettings;
log: string; log: string;
serializableRun: object; runId: string;
binaryRunUrl: string; serializableOutput: Record<string, any[]>;
binaryOutput: Record<string, any>;
} }
interface RunCreationAttributes extends Optional<RunAttributes, 'id'> { } interface RunCreationAttributes extends Optional<RunAttributes, 'id'> { }
class Run extends Model<RunAttributes, RunCreationAttributes> implements RunAttributes { class Run extends Model<RunAttributes, RunCreationAttributes> implements RunAttributes {
public id!: string; public id!: string;
public robotId!: string;
public status!: string; public status!: string;
public name!: string; public name!: string;
public startedAt!: Date; public robotId!: string;
public finishedAt!: Date; public startedAt!: string;
public finishedAt!: string;
public browserId!: string; public browserId!: string;
public interpreterSettings!: object; public interpreterSettings!: InterpreterSettings;
public log!: string; public log!: string;
public serializableRun!: object; public runId!: string;
public binaryRunUrl!: string; public serializableOutput!: Record<string, any[]>;
public binaryOutput!: Record<string, any>;
} }
Run.init( Run.init(
@@ -39,14 +47,6 @@ Run.init(
defaultValue: DataTypes.UUIDV4, defaultValue: DataTypes.UUIDV4,
primaryKey: true, primaryKey: true,
}, },
robotId: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: Robot,
key: 'id',
},
},
status: { status: {
type: DataTypes.STRING(50), type: DataTypes.STRING(50),
allowNull: false, allowNull: false,
@@ -55,12 +55,20 @@ Run.init(
type: DataTypes.STRING(255), type: DataTypes.STRING(255),
allowNull: false, allowNull: false,
}, },
robotId: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: Robot,
key: 'id',
},
},
startedAt: { startedAt: {
type: DataTypes.DATE, type: DataTypes.STRING(255),
allowNull: false, allowNull: false,
}, },
finishedAt: { finishedAt: {
type: DataTypes.DATE, type: DataTypes.STRING(255),
allowNull: false, allowNull: false,
}, },
browserId: { browserId: {
@@ -69,18 +77,22 @@ Run.init(
}, },
interpreterSettings: { interpreterSettings: {
type: DataTypes.JSONB, type: DataTypes.JSONB,
allowNull: true, allowNull: false,
}, },
log: { log: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
allowNull: true, allowNull: true,
}, },
serializableRun: { runId: {
type: DataTypes.UUID,
allowNull: false,
},
serializableOutput: {
type: DataTypes.JSONB, type: DataTypes.JSONB,
allowNull: true, allowNull: true,
}, },
binaryRunUrl: { binaryOutput: {
type: DataTypes.TEXT, type: DataTypes.JSONB,
allowNull: true, allowNull: true,
}, },
}, },