mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
chore: fetch stargazers data from stargazers api
This commit is contained in:
committed by
Mythie
parent
a78ed42f6c
commit
fdd3d7c6fe
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
Reference in New Issue
Block a user