refactor(plugin-workflow): change column type of executed from boolean to integer (#411)
This commit is contained in:
parent
19ee42257e
commit
80a685f8bf
@ -3,7 +3,7 @@ import Database from '@nocobase/database';
|
||||
import { getApp } from '.';
|
||||
import { BRANCH_INDEX, EXECUTION_STATUS, JOB_STATUS } from '../constants';
|
||||
|
||||
jest.setTimeout(300000);
|
||||
|
||||
|
||||
describe('execution', () => {
|
||||
let app: Application;
|
||||
|
@ -10,34 +10,29 @@ export default {
|
||||
type: 'uid'
|
||||
},
|
||||
{
|
||||
interface: 'string',
|
||||
type: 'string',
|
||||
name: 'title',
|
||||
title: '工作流名称',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
interface: 'boolean',
|
||||
type: 'boolean',
|
||||
name: 'enabled',
|
||||
title: '启用',
|
||||
defaultValue: false
|
||||
},
|
||||
{
|
||||
interface: 'textarea',
|
||||
type: 'text',
|
||||
name: 'description',
|
||||
title: '描述'
|
||||
},
|
||||
{
|
||||
interface: 'select',
|
||||
type: 'string',
|
||||
title: '触发方式',
|
||||
name: 'type',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
interface: 'json',
|
||||
type: 'jsonb',
|
||||
title: '触发配置',
|
||||
name: 'config',
|
||||
@ -45,30 +40,27 @@ export default {
|
||||
defaultValue: {}
|
||||
},
|
||||
{
|
||||
interface: 'boolean',
|
||||
type: 'boolean',
|
||||
title: '使用事务',
|
||||
name: 'useTransaction',
|
||||
defaultValue: true
|
||||
},
|
||||
{
|
||||
interface: 'linkTo',
|
||||
type: 'hasMany',
|
||||
name: 'nodes',
|
||||
target: 'flow_nodes',
|
||||
title: '流程节点'
|
||||
},
|
||||
{
|
||||
interface: 'linkTo',
|
||||
type: 'hasMany',
|
||||
name: 'executions',
|
||||
target: 'executions',
|
||||
title: '触发执行'
|
||||
},
|
||||
{
|
||||
type: 'boolean',
|
||||
type: 'integer',
|
||||
name: 'executed',
|
||||
defaultValue: false
|
||||
defaultValue: 0
|
||||
},
|
||||
{
|
||||
type: 'boolean',
|
||||
|
@ -15,7 +15,7 @@ export default class WorkflowModel extends Model {
|
||||
declare type: string;
|
||||
declare config: any;
|
||||
declare useTransaction: boolean;
|
||||
declare executed: boolean;
|
||||
declare executed: number;
|
||||
|
||||
declare createdAt: Date;
|
||||
declare updatedAt: Date;
|
||||
@ -68,15 +68,15 @@ export default class WorkflowModel extends Model {
|
||||
transaction: transaction.id
|
||||
}, { transaction });
|
||||
|
||||
const executed = await this.countExecutions({ transaction });
|
||||
|
||||
// NOTE: not to trigger afterUpdate hook here
|
||||
await this.update({ executed }, { transaction, hooks: false });
|
||||
|
||||
execution.workflow = this;
|
||||
|
||||
await execution.start({ transaction });
|
||||
|
||||
if (!this.executed) {
|
||||
// NOTE: not to trigger afterUpdate hook here
|
||||
await this.update({ executed: true }, { transaction, hooks: false });
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
if (transaction && (!options.transaction || options.transaction.finished)) {
|
||||
await transaction.commit();
|
||||
|
Loading…
Reference in New Issue
Block a user