refactor: Get last execution and find last internal ID
This commit is contained in:
@@ -4,6 +4,7 @@ import Base from './base';
|
||||
import Step from './step';
|
||||
import Execution from './execution';
|
||||
import Telemetry from '../helpers/telemetry';
|
||||
import { IExecution } from '@automatisch/types';
|
||||
|
||||
class Flow extends Base {
|
||||
id!: string;
|
||||
@@ -50,11 +51,11 @@ class Flow extends Base {
|
||||
});
|
||||
|
||||
async lastInternalId() {
|
||||
const lastInternalIdFetched: any = await this.$relatedQuery(
|
||||
'executions'
|
||||
).max('internal_id');
|
||||
const lastExecution = await this.$relatedQuery('executions')
|
||||
.orderBy('created_at', 'desc')
|
||||
.first();
|
||||
|
||||
return lastInternalIdFetched[0].max;
|
||||
return (lastExecution as Execution).internalId;
|
||||
}
|
||||
|
||||
async $beforeUpdate(
|
||||
|
Reference in New Issue
Block a user