refactor: Remove early exit strategy for twitter triggers
This commit is contained in:
@@ -52,25 +52,22 @@ const searchTweets = async (
|
||||
|
||||
if (response.data.meta.result_count > 0) {
|
||||
response.data.data.forEach((tweet: IJSONObject) => {
|
||||
if (
|
||||
!options.lastInternalId ||
|
||||
Number(tweet.id) > Number(options.lastInternalId)
|
||||
) {
|
||||
const dataItem = {
|
||||
raw: tweet,
|
||||
meta: {
|
||||
internalId: tweet.id as string,
|
||||
},
|
||||
};
|
||||
const dataItem = {
|
||||
raw: tweet,
|
||||
meta: {
|
||||
internalId: tweet.id as string,
|
||||
},
|
||||
};
|
||||
|
||||
tweets.data.push(dataItem);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
tweets.data.push(dataItem);
|
||||
});
|
||||
}
|
||||
} while (response.data.meta.next_token && options.lastInternalId);
|
||||
|
||||
tweets.data.sort((tweet, nextTweet) => {
|
||||
return (tweet.raw.id as number) - (nextTweet.raw.id as number);
|
||||
});
|
||||
|
||||
return tweets;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user