fix: Do not sort user tweets since it's in reverse-chronological order
This commit is contained in:
@@ -12,8 +12,6 @@ import getUserByUsername from './get-user-by-username';
|
||||
|
||||
type IGetUserTweetsOptions = {
|
||||
currentUser: boolean;
|
||||
userId?: string;
|
||||
lastInternalId?: string;
|
||||
};
|
||||
|
||||
const getUserTweets = async (
|
||||
@@ -39,7 +37,7 @@ const getUserTweets = async (
|
||||
|
||||
do {
|
||||
const params: IJSONObject = {
|
||||
since_id: options.lastInternalId,
|
||||
since_id: $.execution.testRun ? null : $.flow.lastInternalId,
|
||||
pagination_token: response?.data?.meta?.next_token,
|
||||
};
|
||||
|
||||
@@ -63,15 +61,13 @@ const getUserTweets = async (
|
||||
response.data.data.forEach((tweet: IJSONObject) => {
|
||||
tweets.data.push({
|
||||
raw: tweet,
|
||||
meta: { internalId: tweet.id as string },
|
||||
meta: {
|
||||
internalId: tweet.id as string,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
} while (response.data.meta.next_token && options.lastInternalId);
|
||||
|
||||
tweets.data.sort((tweet, nextTweet) => {
|
||||
return (tweet.raw.id as number) - (nextTweet.raw.id as number);
|
||||
});
|
||||
} while (response.data.meta.next_token && !$.execution.testRun);
|
||||
|
||||
return tweets;
|
||||
};
|
||||
|
@@ -20,7 +20,6 @@ export default {
|
||||
async run($: IGlobalVariable) {
|
||||
return await getUserTweets($, {
|
||||
currentUser: true,
|
||||
lastInternalId: $.flow.lastInternalId,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
@@ -32,8 +32,6 @@ export default {
|
||||
async run($: IGlobalVariable) {
|
||||
return await getUserTweets($, {
|
||||
currentUser: false,
|
||||
userId: $.step.parameters.username as string,
|
||||
lastInternalId: $.flow.lastInternalId,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user