Skip to content

The Open Source DocuSign Alternative.

chore: fetch stargazers data from stargazers api

Ephraim Atta-Duncanfdd3d7c6fe5a
diff --git a/apps/marketing/src/app/(marketing)/open/gh-stars.tsx b/apps/marketing/src/app/(marketing)/open/gh-stars.tsx
index 4d1d03254..4d5137a6a 100644
--- a/apps/marketing/src/app/(marketing)/open/gh-stars.tsx
+++ b/apps/marketing/src/app/(marketing)/open/gh-stars.tsx
@@ -15,45 +15,6 @@ type StargazersType = {
};
};
-const data: StargazersType = {
- '2023-8': {
- stars: 2483,
- forks: 155,
- mergedPRs: 87,
- openIssues: 67,
- },
- '2023-7': {
- stars: 2250,
- forks: 0,
- mergedPRs: 0,
- openIssues: 0,
- },
- '2023-6': {
- stars: 2070,
- forks: 0,
- mergedPRs: 0,
- openIssues: 0,
- },
- '2023-5': {
- stars: 1260,
- forks: 0,
- mergedPRs: 0,
- openIssues: 0,
- },
- '2023-4': {
- stars: 90,
- forks: 0,
- mergedPRs: 0,
- openIssues: 0,
- },
- '2023-3': {
- stars: 0,
- forks: 0,
- mergedPRs: 0,
- openIssues: 0,
- },
-};
-
function formatMonth(monthStr: string) {
const [year, month] = monthStr.split('-');
const monthNames = [
@@ -73,16 +34,16 @@ function formatMonth(monthStr: string) {
return `${monthNames[parseInt(month, 10) - 1]} ${year}`;
}
-const formattedData = Object.keys(data)
- .map((key) => ({
- month: formatMonth(key),
- stars: data[key].stars,
- }))
- .reverse();
+export type GithubStarsProps = HTMLAttributes<HTMLDivElement> & { data: StargazersType };
-export type GithubStarsProps = HTMLAttributes<HTMLDivElement>;
+export const GithubStars = ({ className, data, ...props }: GithubStarsProps) => {
+ const formattedData = Object.keys(data)
+ .map((key) => ({
+ month: formatMonth(key),
+ stars: data[key].stars,
+ }))
+ .reverse();
-export const GithubStars = ({ className, ...props }: GithubStarsProps) => {
return (
<div className={cn('flex flex-col', className)} {...props}>
<h3 className="px-4 text-lg font-semibold">Github Monthly Stars</h3>
diff --git a/apps/marketing/src/app/(marketing)/open/page.tsx b/apps/marketing/src/app/(marketing)/open/page.tsx
index bc7740b5a..d31ae067b 100644
--- a/apps/marketing/src/app/(marketing)/open/page.tsx
+++ b/apps/marketing/src/app/(marketing)/open/page.tsx
@@ -20,6 +20,17 @@ const ZMergedPullRequestsResponse = z.object({
total_count: z.number(),
});
+const ZStargazersLiveResponse = z.record(
+ z.object({
+ stars: z.number(),
+ forks: z.number(),
+ mergedPRs: z.number(),
+ openIssues: z.number(),
+ }),
+);
+
+export type StargazersType = z.infer<typeof ZStargazersLiveResponse>;
+
// const ZOpenPullRequestsResponse = ZMergedPullRequestsResponse;
export default async function OpenPage() {
@@ -46,6 +57,14 @@ export default async function OpenPage() {
.then((res) => res.json())
.then((res) => ZMergedPullRequestsResponse.parse(res));
+ const STARGAZERS_DATA = await fetch('https://stargrazer-live.onrender.com/api/stats', {
+ headers: {
+ accept: 'application/json',
+ },
+ })
+ .then((res) => res.json())
+ .then((res) => ZStargazersLiveResponse.parse(res));
+
return (
<div className="mx-auto mt-12 max-w-screen-lg">
<div className="flex flex-col items-center justify-center">
@@ -88,7 +107,7 @@ export default async function OpenPage() {
<FundingRaised className="col-span-12 lg:col-span-6" />
<CapTable className="col-span-12 lg:col-span-6" />
- <GithubStars className="col-span-12 lg:col-span-6" />
+ <GithubStars className="col-span-12 lg:col-span-6" data={STARGAZERS_DATA} />
<div className="col-span-12 mt-12 flex flex-col items-center justify-center">
<h2 className="text-2xl font-bold">Where's the rest?</h2>