refactor: Restructure apps with new data pushing logic

This commit is contained in:
Faruk AYDIN
2022-10-22 19:29:02 +02:00
parent bcff9f5a9e
commit a56135ca57
19 changed files with 115 additions and 136 deletions

View File

@@ -1,8 +1,4 @@
import {
IGlobalVariable,
IJSONObject,
ITriggerOutput,
} from '@automatisch/types';
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
import { URLSearchParams } from 'url';
import { omitBy, isEmpty } from 'lodash';
@@ -16,10 +12,6 @@ const getUserFollowers = async (
) => {
let response;
const followers: ITriggerOutput = {
data: [],
};
do {
const params: IJSONObject = {
pagination_token: response?.data?.meta?.next_token,
@@ -40,18 +32,16 @@ const getUserFollowers = async (
if (response.data.meta.result_count > 0) {
for (const follower of response.data.data) {
if ($.flow.isAlreadyProcessed(follower.id as string)) {
return followers;
return;
}
followers.data.push({
$.pushTriggerItem({
raw: follower,
meta: { internalId: follower.id as string },
});
}
}
} while (response.data.meta.next_token && !$.execution.testRun);
return followers;
};
export default getUserFollowers;