Skip to content

Commit 77be7ea

Browse files
committed
cleanup contributors
1 parent f4c3e4d commit 77be7ea

File tree

3 files changed

+309
-143
lines changed

3 files changed

+309
-143
lines changed

apps/docs/app/(home)/contributors/code-churn-chart.tsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,16 @@ export default function CodeChurnChart({ data }: Props) {
141141
if (!chartData.length) {
142142
return (
143143
<div>
144-
<div className="mb-8">
145-
<h3 className="mb-2 font-semibold text-2xl sm:text-3xl lg:text-4xl">
144+
<div className="mb-6 sm:mb-8">
145+
<h3 className="mb-2 font-semibold text-xl sm:text-2xl lg:text-3xl xl:text-4xl">
146146
Code Churn Activity
147147
</h3>
148148
<p className="text-muted-foreground text-sm sm:text-base lg:text-lg">
149149
Weekly code additions and deletions over time
150150
</p>
151151
</div>
152-
<div className="group relative rounded border border-border bg-card/50 p-8 backdrop-blur-sm">
153-
<div className="py-8 text-center text-muted-foreground">
152+
<div className="group relative rounded border border-border bg-card/50 p-6 backdrop-blur-sm sm:p-8">
153+
<div className="py-6 text-center text-muted-foreground text-sm sm:py-8 sm:text-base">
154154
No code frequency data available
155155
</div>
156156

@@ -180,23 +180,27 @@ export default function CodeChurnChart({ data }: Props) {
180180

181181
return (
182182
<div>
183-
<div className="mb-8">
184-
<h3 className="mb-2 font-semibold text-2xl sm:text-3xl lg:text-4xl">
183+
<div className="mb-6 sm:mb-8">
184+
<h3 className="mb-2 font-semibold text-xl sm:text-2xl lg:text-3xl xl:text-4xl">
185185
Code Churn Activity
186186
</h3>
187187
<p className="text-muted-foreground text-sm sm:text-base lg:text-lg">
188188
Weekly code additions and deletions over the last 6 months •{' '}
189-
{insights.totalAdditions.toLocaleString()} lines added
189+
<span className="font-medium">
190+
{insights.totalAdditions.toLocaleString()} lines added
191+
</span>
190192
</p>
191193
</div>
192194

193195
{/* Insights Cards */}
194-
<div className="mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
195-
<div className="group relative rounded border border-border bg-card/50 p-6 backdrop-blur-sm transition-all duration-300 hover:border-border/80 hover:bg-card/70">
196-
<div className="font-bold text-2xl text-green-600">
196+
<div className="mb-6 grid grid-cols-2 gap-3 sm:mb-8 sm:grid-cols-2 sm:gap-4 lg:grid-cols-4">
197+
<div className="group relative rounded border border-border bg-card/50 p-4 backdrop-blur-sm transition-all duration-300 hover:border-border/80 hover:bg-card/70 sm:p-6">
198+
<div className="font-bold text-green-600 text-lg sm:text-2xl">
197199
+{insights.totalAdditions.toLocaleString()}
198200
</div>
199-
<div className="text-muted-foreground text-sm">Total Added</div>
201+
<div className="text-muted-foreground text-xs sm:text-sm">
202+
Total Added
203+
</div>
200204

201205
{/* Sci-fi corners */}
202206
<div className="pointer-events-none absolute inset-0">
@@ -219,11 +223,13 @@ export default function CodeChurnChart({ data }: Props) {
219223
</div>
220224
</div>
221225

222-
<div className="group relative rounded border border-border bg-card/50 p-6 backdrop-blur-sm transition-all duration-300 hover:border-border/80 hover:bg-card/70">
223-
<div className="font-bold text-2xl text-red-600">
226+
<div className="group relative rounded border border-border bg-card/50 p-4 backdrop-blur-sm transition-all duration-300 hover:border-border/80 hover:bg-card/70 sm:p-6">
227+
<div className="font-bold text-lg text-red-600 sm:text-2xl">
224228
-{insights.totalDeletions.toLocaleString()}
225229
</div>
226-
<div className="text-muted-foreground text-sm">Total Removed</div>
230+
<div className="text-muted-foreground text-xs sm:text-sm">
231+
Total Removed
232+
</div>
227233

228234
{/* Sci-fi corners */}
229235
<div className="pointer-events-none absolute inset-0">
@@ -246,14 +252,16 @@ export default function CodeChurnChart({ data }: Props) {
246252
</div>
247253
</div>
248254

249-
<div className="group relative rounded border border-border bg-card/50 p-6 backdrop-blur-sm transition-all duration-300 hover:border-border/80 hover:bg-card/70">
255+
<div className="group relative rounded border border-border bg-card/50 p-4 backdrop-blur-sm transition-all duration-300 hover:border-border/80 hover:bg-card/70 sm:p-6">
250256
<div
251-
className={`font-bold text-2xl ${insights.netGrowth >= 0 ? 'text-green-600' : 'text-red-600'}`}
257+
className={`font-bold text-lg sm:text-2xl ${insights.netGrowth >= 0 ? 'text-green-600' : 'text-red-600'}`}
252258
>
253259
{insights.netGrowth >= 0 ? '+' : ''}
254260
{insights.netGrowth.toLocaleString()}
255261
</div>
256-
<div className="text-muted-foreground text-sm">Net Growth</div>
262+
<div className="text-muted-foreground text-xs sm:text-sm">
263+
Net Growth
264+
</div>
257265

258266
{/* Sci-fi corners */}
259267
<div className="pointer-events-none absolute inset-0">

apps/docs/app/(home)/contributors/page.tsx

Lines changed: 76 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Metadata } from 'next';
2+
import { cache } from 'react';
23
import { Footer } from '@/components/footer';
34
import Section from '@/components/landing/section';
45
import { Spotlight } from '@/components/landing/spotlight';
@@ -125,59 +126,75 @@ function fetchWithRetry(
125126
return attemptFetch(1);
126127
}
127128

128-
async function fetchBasicRepoData(requestInit: RequestInit) {
129+
function fetchBasicRepoData(requestInit: RequestInit): Promise<GitHubRepo> {
129130
// Fetch repository info
130-
const repoResponse = await fetch(
131-
'https://api.github.com/repos/databuddy-analytics/Databuddy',
132-
requestInit
133-
);
134-
if (!repoResponse.ok) {
135-
throw new Error(`Failed to fetch repo: ${repoResponse.status}`);
136-
}
137-
return await repoResponse.json();
131+
const cachedRepoResponse = cache(async () => {
132+
const repoResponse = await fetch(
133+
'https://api.github.com/repos/databuddy-analytics/Databuddy',
134+
requestInit
135+
);
136+
if (!repoResponse.ok) {
137+
throw new Error(`Failed to fetch repo: ${repoResponse.status}`);
138+
}
139+
return await repoResponse.json();
140+
});
141+
return cachedRepoResponse();
138142
}
139143

140-
async function fetchContributorsData(requestInit: RequestInit) {
141-
const contributorsResponse = await fetch(
142-
'https://api.github.com/repos/databuddy-analytics/Databuddy/contributors?per_page=100',
143-
requestInit
144-
);
145-
if (!contributorsResponse.ok) {
146-
throw new Error(
147-
`Failed to fetch contributors: ${contributorsResponse.status}`
144+
function fetchContributorsData(
145+
requestInit: RequestInit
146+
): Promise<GitHubContributor[]> {
147+
const cachedContributorsResponse = cache(async () => {
148+
const contributorsResponse = await fetch(
149+
'https://api.github.com/repos/databuddy-analytics/Databuddy/contributors?per_page=100',
150+
requestInit
148151
);
149-
}
150-
const contributorsData = await contributorsResponse.json();
151-
return Array.isArray(contributorsData) ? contributorsData : [];
152+
if (!contributorsResponse.ok) {
153+
throw new Error(
154+
`Failed to fetch contributors: ${contributorsResponse.status}`
155+
);
156+
}
157+
return await contributorsResponse.json();
158+
});
159+
return cachedContributorsResponse();
152160
}
153161

154-
async function fetchLanguagesData(requestInit: RequestInit) {
155-
const languagesResponse = await fetch(
156-
'https://api.github.com/repos/databuddy-analytics/Databuddy/languages',
157-
requestInit
158-
);
159-
if (!languagesResponse.ok) {
160-
throw new Error(`Failed to fetch languages: ${languagesResponse.status}`);
161-
}
162-
return await languagesResponse.json();
162+
function fetchLanguagesData(
163+
requestInit: RequestInit
164+
): Promise<GitHubLanguages> {
165+
const cachedLanguagesResponse = cache(async () => {
166+
const languagesResponse = await fetch(
167+
'https://api.github.com/repos/databuddy-analytics/Databuddy/languages',
168+
requestInit
169+
);
170+
if (!languagesResponse.ok) {
171+
throw new Error(`Failed to fetch languages: ${languagesResponse.status}`);
172+
}
173+
return await languagesResponse.json();
174+
});
175+
return cachedLanguagesResponse();
163176
}
164177

165-
async function fetchPullRequestsData(requestInit: RequestInit) {
166-
const prsResponse = await fetch(
167-
'https://api.github.com/repos/databuddy-analytics/Databuddy/pulls?state=all&per_page=100',
168-
requestInit
169-
);
170-
if (!prsResponse.ok) {
171-
throw new Error(`Failed to fetch PRs: ${prsResponse.status}`);
172-
}
173-
const prsData = await prsResponse.json();
174-
return Array.isArray(prsData) ? prsData : [];
178+
function fetchPullRequestsData(
179+
requestInit: RequestInit
180+
): Promise<GitHubPullRequest[]> {
181+
const cachedPrsResponse = cache(async () => {
182+
const prsResponse = await fetch(
183+
'https://api.github.com/repos/databuddy-analytics/Databuddy/pulls?state=all&per_page=100',
184+
requestInit
185+
);
186+
if (!prsResponse.ok) {
187+
throw new Error(`Failed to fetch PRs: ${prsResponse.status}`);
188+
}
189+
return await prsResponse.json();
190+
});
191+
return cachedPrsResponse();
175192
}
176193

177-
async function fetchCommitActivity(
194+
function fetchCommitActivity(
178195
statsRequestInit: RequestInit
179196
): Promise<ProcessedCommitActivity[]> {
180-
try {
197+
const cachedCommitActivityResponse = cache(async () => {
181198
const response = await fetchWithRetry(
182199
'https://api.github.com/repos/databuddy-analytics/Databuddy/stats/commit_activity',
183200
statsRequestInit
@@ -211,17 +228,15 @@ async function fetchCommitActivity(
211228
`GitHub API returned ${response.status} for commit activity`
212229
);
213230
}
214-
} catch (error) {
215-
console.error('Failed to fetch commit activity:', error);
216-
}
217-
218-
return statsCache.commitActivity || [];
231+
return [];
232+
});
233+
return cachedCommitActivityResponse();
219234
}
220235

221-
async function fetchCodeFrequency(
236+
function fetchCodeFrequency(
222237
statsRequestInit: RequestInit
223238
): Promise<ProcessedCodeFrequency[]> {
224-
try {
239+
const cachedCodeFrequencyResponse = cache(async () => {
225240
const response = await fetchWithRetry(
226241
'https://api.github.com/repos/databuddy-analytics/Databuddy/stats/code_frequency',
227242
statsRequestInit
@@ -247,17 +262,16 @@ async function fetchCodeFrequency(
247262
} else {
248263
console.warn(`GitHub API returned ${response.status} for code frequency`);
249264
}
250-
} catch (error) {
251-
console.error('Failed to fetch code frequency:', error);
252-
}
265+
return [];
266+
});
253267

254-
return statsCache.codeFrequency || [];
268+
return cachedCodeFrequencyResponse();
255269
}
256270

257-
async function fetchPunchCard(
271+
function fetchPunchCard(
258272
statsRequestInit: RequestInit
259273
): Promise<ProcessedPunchCard[]> {
260-
try {
274+
const cachedPunchCardResponse = cache(async () => {
261275
const response = await fetchWithRetry(
262276
'https://api.github.com/repos/databuddy-analytics/Databuddy/stats/punch_card',
263277
statsRequestInit
@@ -284,18 +298,13 @@ async function fetchPunchCard(
284298
} else {
285299
console.warn(`GitHub API returned ${response.status} for punch card`);
286300
}
287-
} catch (error) {
288-
console.error('Failed to fetch punch card:', error);
289-
}
290-
291-
// Return cached data if available, otherwise empty array
292-
return statsCache.punchCard || [];
301+
return [];
302+
});
303+
return cachedPunchCardResponse();
293304
}
294305

295-
async function fetchReleases(
296-
requestInit: RequestInit
297-
): Promise<ProcessedRelease[]> {
298-
try {
306+
function fetchReleases(requestInit: RequestInit): Promise<ProcessedRelease[]> {
307+
const cachedReleasesResponse = cache(async () => {
299308
const response = await fetch(
300309
'https://api.github.com/repos/databuddy-analytics/Databuddy/releases?per_page=20',
301310
requestInit
@@ -316,10 +325,9 @@ async function fetchReleases(
316325
.slice(0, 10); // Latest 10 releases
317326
}
318327
}
319-
} catch (error) {
320-
console.error('Failed to fetch releases:', error);
321-
}
322-
return [];
328+
return [];
329+
});
330+
return cachedReleasesResponse();
323331
}
324332

325333
async function fetchGitHubData() {

0 commit comments

Comments
 (0)