Compare commits
1 Commits
AUT-500
...
feature/er
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d86dbf7bd9 |
@@ -47,6 +47,8 @@ export default class SearchTweets {
|
|||||||
headers: { ...authHeader },
|
headers: { ...authHeader },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
|
||||||
if (response.data.meta.result_count > 0) {
|
if (response.data.meta.result_count > 0) {
|
||||||
response.data.data.forEach((tweet: IJSONObject) => {
|
response.data.data.forEach((tweet: IJSONObject) => {
|
||||||
if (!lastInternalId || Number(tweet.id) > Number(lastInternalId)) {
|
if (!lastInternalId || Number(tweet.id) > Number(lastInternalId)) {
|
||||||
@@ -59,15 +61,10 @@ export default class SearchTweets {
|
|||||||
} while (response.data.meta.next_token && lastInternalId);
|
} while (response.data.meta.next_token && lastInternalId);
|
||||||
|
|
||||||
if (response.data?.errors) {
|
if (response.data?.errors) {
|
||||||
const errorMessages = response.data.errors
|
const errors = response.data.errors;
|
||||||
.map((error: IJSONObject) => error.detail)
|
return { errors, data: tweets };
|
||||||
.join(' ');
|
|
||||||
|
|
||||||
throw new Error(
|
|
||||||
`Error occured while fetching user data: ${errorMessages}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tweets;
|
return { data: tweets };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@ export default class HttpClient {
|
|||||||
constructor(params: IHttpClientParams) {
|
constructor(params: IHttpClientParams) {
|
||||||
this.instance = axios.create({
|
this.instance = axios.create({
|
||||||
baseURL: params.baseURL,
|
baseURL: params.baseURL,
|
||||||
|
validateStatus: () => true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,9 +33,9 @@ class Processor {
|
|||||||
|
|
||||||
const triggerStep = steps.find((step) => step.type === 'trigger');
|
const triggerStep = steps.find((step) => step.type === 'trigger');
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
let initialTriggerData = await this.getInitialTriggerData(triggerStep!);
|
const initialTriggerData = await this.getInitialTriggerData(triggerStep!);
|
||||||
|
|
||||||
if (initialTriggerData.length === 0) {
|
if (initialTriggerData.data.length === 0) {
|
||||||
const lastInternalId = await this.flow.lastInternalId();
|
const lastInternalId = await this.flow.lastInternalId();
|
||||||
|
|
||||||
const executionData: Partial<Execution> = {
|
const executionData: Partial<Execution> = {
|
||||||
@@ -53,11 +53,11 @@ class Processor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.testRun) {
|
if (this.testRun) {
|
||||||
initialTriggerData = [initialTriggerData[0]];
|
initialTriggerData.data = [initialTriggerData.data[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initialTriggerData.length > 1) {
|
if (initialTriggerData.data.length > 1) {
|
||||||
initialTriggerData = initialTriggerData.sort(
|
initialTriggerData.data = initialTriggerData.data.sort(
|
||||||
(item: IJSONObject, nextItem: IJSONObject) => {
|
(item: IJSONObject, nextItem: IJSONObject) => {
|
||||||
return (item.id as number) - (nextItem.id as number);
|
return (item.id as number) - (nextItem.id as number);
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ class Processor {
|
|||||||
|
|
||||||
const executions: Execution[] = [];
|
const executions: Execution[] = [];
|
||||||
|
|
||||||
for await (const data of initialTriggerData) {
|
for await (const data of initialTriggerData.data) {
|
||||||
const execution = await Execution.query().insert({
|
const execution = await Execution.query().insert({
|
||||||
flowId: this.flow.id,
|
flowId: this.flow.id,
|
||||||
testRun: this.testRun,
|
testRun: this.testRun,
|
||||||
@@ -118,6 +118,23 @@ class Processor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (initialTriggerData.errors) {
|
||||||
|
const execution = await Execution.query().insert({
|
||||||
|
flowId: this.flow.id,
|
||||||
|
testRun: this.testRun,
|
||||||
|
internalId: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
await ExecutionStep.query().insert({
|
||||||
|
executionId: execution.id,
|
||||||
|
stepId: steps[0].id,
|
||||||
|
status: 'failure',
|
||||||
|
dataIn: steps[0].parameters,
|
||||||
|
dataOut: null,
|
||||||
|
errorDetails: initialTriggerData.errors,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.testRun) return;
|
if (!this.testRun) return;
|
||||||
|
|
||||||
const lastExecutionStepFromFirstExecution = await executions[0]
|
const lastExecutionStepFromFirstExecution = await executions[0]
|
||||||
|
Reference in New Issue
Block a user