Merge pull request #600 from automatisch/refactor/remove-search-term

refactor: Do not expose search term separately for search tweets
This commit is contained in:
Ömer Faruk Aydın
2022-10-14 23:53:52 +02:00
committed by GitHub
2 changed files with 4 additions and 12 deletions

View File

@@ -31,8 +31,6 @@ export default {
], ],
async run($: IGlobalVariable) { async run($: IGlobalVariable) {
return await searchTweets($, { return await searchTweets($);
searchTerm: $.step.parameters.searchTerm as string,
});
}, },
}; };

View File

@@ -7,15 +7,9 @@ import qs from 'qs';
import generateRequest from '../../common/generate-request'; import generateRequest from '../../common/generate-request';
import { omitBy, isEmpty } from 'lodash'; import { omitBy, isEmpty } from 'lodash';
type ISearchTweetsOptions = { const searchTweets = async ($: IGlobalVariable) => {
searchTerm: string; const searchTerm = $.step.parameters.searchTerm as string;
lastInternalId?: string;
};
const searchTweets = async (
$: IGlobalVariable,
options: ISearchTweetsOptions
) => {
let response; let response;
const tweets: ITriggerOutput = { const tweets: ITriggerOutput = {
@@ -24,7 +18,7 @@ const searchTweets = async (
do { do {
const params: IJSONObject = { const params: IJSONObject = {
query: options.searchTerm, query: searchTerm,
since_id: $.execution.testRun ? null : $.flow.lastInternalId, since_id: $.execution.testRun ? null : $.flow.lastInternalId,
pagination_token: response?.data?.meta?.next_token, pagination_token: response?.data?.meta?.next_token,
}; };