Skip to content

Commit 424bde3

Browse files
committed
Fix RateLimit
1 parent 5ec4a86 commit 424bde3

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

app/[username]/page.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ const page = async ({ params: { username } }) => {
6363
userStats,
6464
topContributions,
6565
followUp,
66+
rateLimit,
6667
},
6768
] = await Promise.all([fetchActivity(username), fetchUserData(username), updateRecentProfilesDb()]);
6869

6970
return (
7071
<main className="mx-auto max-w-screen-xl space-y-8 px-3 pb-10 md:space-y-16">
71-
<RateLimit />
72+
<RateLimit limit={rateLimit} />
7273
<UserInfo username={username} {...userInfo} />
7374
<Stats stats={userStats} />
7475
<Languages languages={languagesSize} />

components/RateLimit.js

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
1-
'ues server';
2-
3-
import githubGraphql from '@/utils/githubGraphql';
4-
import { unstable_noStore } from 'next/cache';
5-
6-
const RateLimit = async () => {
7-
unstable_noStore();
8-
const query = `
9-
query{
10-
rateLimit{
11-
cost
12-
limit
13-
remaining
14-
used
15-
resetAt
16-
}
17-
}
18-
`;
19-
20-
const { rateLimit } = await githubGraphql({ query });
21-
1+
const RateLimit = async ({ limit }) => {
222
return (
23-
<div className="fixed bottom-0 right-0 hidden md:block z-20 border border-gray-700 bg-gray-800 px-3 md:px-4 py-2 text-xs shadow-xl shadow-gray-900 md:bottom-8 md:right-6 md:text-sm">
3+
<div className="fixed bottom-0 right-0 z-20 hidden border border-gray-700 bg-gray-800 px-3 py-2 text-xs shadow-xl shadow-gray-900 md:bottom-8 md:right-6 md:block md:px-4 md:text-sm">
244
<p>
25-
<span className=" text-sm font-bold md:text-base">{rateLimit.remaining}</span> requests left <br />{' '}
26-
before rate-limit
5+
<span className=" text-sm font-bold md:text-base">{limit.remaining}</span> requests left <br /> before
6+
rate-limit
277
</p>
288
</div>
299
);

utils/fetchUserData.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ const fetchUserData = async login => {
264264
topContributions,
265265
userStats,
266266
followUp,
267+
rateLimit
267268
};
268269
};
269270

0 commit comments

Comments
 (0)