Skip to content

Commit 6e0a044

Browse files
committed
feat: sort followers on the basis of date
1 parent 2233319 commit 6e0a044

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/src/fetchFollowers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ const getLatestFollowers = async () => {
4242
const formattedFollowers = followers.map((follower) => ({
4343
profileUrl: follower.html_url,
4444
picUrl: follower.avatar_url,
45+
followedAt: follower.created_at,
4546
}));
4647

4748
formattedFollowers.sort((a, b) => {
48-
return a.profileUrl.localeCompare(b.profileUrl);
49+
return new Date(a.followedAt) - new Date(b.followedAt);
4950
});
5051

5152
return formattedFollowers;
5253
} catch (error) {
5354
console.error("Error fetching followers:", error.message);
5455
}
5556
};
56-
5757
export async function handleFetchFollowers() {
5858
const followers = await getLatestFollowers();
5959
const followersLength = followers.length;

0 commit comments

Comments
 (0)