refactor: Get last execution and find last internal ID
This commit is contained in:
@@ -26,9 +26,7 @@ export default class GetUserTweets {
|
|||||||
pagination_token: response?.data?.meta?.next_token,
|
pagination_token: response?.data?.meta?.next_token,
|
||||||
};
|
};
|
||||||
|
|
||||||
const queryParams = new URLSearchParams({
|
const queryParams = new URLSearchParams(omitBy(params, isEmpty));
|
||||||
...omitBy(params, isEmpty),
|
|
||||||
});
|
|
||||||
|
|
||||||
const requestPath = `/2/users/${userId}/tweets${
|
const requestPath = `/2/users/${userId}/tweets${
|
||||||
queryParams.toString() ? `?${queryParams.toString()}` : ''
|
queryParams.toString() ? `?${queryParams.toString()}` : ''
|
||||||
|
@@ -4,6 +4,7 @@ import Base from './base';
|
|||||||
import Step from './step';
|
import Step from './step';
|
||||||
import Execution from './execution';
|
import Execution from './execution';
|
||||||
import Telemetry from '../helpers/telemetry';
|
import Telemetry from '../helpers/telemetry';
|
||||||
|
import { IExecution } from '@automatisch/types';
|
||||||
|
|
||||||
class Flow extends Base {
|
class Flow extends Base {
|
||||||
id!: string;
|
id!: string;
|
||||||
@@ -50,11 +51,11 @@ class Flow extends Base {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async lastInternalId() {
|
async lastInternalId() {
|
||||||
const lastInternalIdFetched: any = await this.$relatedQuery(
|
const lastExecution = await this.$relatedQuery('executions')
|
||||||
'executions'
|
.orderBy('created_at', 'desc')
|
||||||
).max('internal_id');
|
.first();
|
||||||
|
|
||||||
return lastInternalIdFetched[0].max;
|
return (lastExecution as Execution).internalId;
|
||||||
}
|
}
|
||||||
|
|
||||||
async $beforeUpdate(
|
async $beforeUpdate(
|
||||||
|
Reference in New Issue
Block a user