mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
chore: fetch stargazers data from stargazers api
This commit is contained in:
@ -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) {
|
function formatMonth(monthStr: string) {
|
||||||
const [year, month] = monthStr.split('-');
|
const [year, month] = monthStr.split('-');
|
||||||
const monthNames = [
|
const monthNames = [
|
||||||
@ -73,16 +34,16 @@ function formatMonth(monthStr: string) {
|
|||||||
return `${monthNames[parseInt(month, 10) - 1]} ${year}`;
|
return `${monthNames[parseInt(month, 10) - 1]} ${year}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formattedData = Object.keys(data)
|
export type GithubStarsProps = HTMLAttributes<HTMLDivElement> & { data: StargazersType };
|
||||||
.map((key) => ({
|
|
||||||
month: formatMonth(key),
|
|
||||||
stars: data[key].stars,
|
|
||||||
}))
|
|
||||||
.reverse();
|
|
||||||
|
|
||||||
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 (
|
return (
|
||||||
<div className={cn('flex flex-col', className)} {...props}>
|
<div className={cn('flex flex-col', className)} {...props}>
|
||||||
<h3 className="px-4 text-lg font-semibold">Github Monthly Stars</h3>
|
<h3 className="px-4 text-lg font-semibold">Github Monthly Stars</h3>
|
||||||
|
|||||||
@ -20,6 +20,17 @@ const ZMergedPullRequestsResponse = z.object({
|
|||||||
total_count: z.number(),
|
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;
|
// const ZOpenPullRequestsResponse = ZMergedPullRequestsResponse;
|
||||||
|
|
||||||
export default async function OpenPage() {
|
export default async function OpenPage() {
|
||||||
@ -46,6 +57,14 @@ export default async function OpenPage() {
|
|||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((res) => ZMergedPullRequestsResponse.parse(res));
|
.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 (
|
return (
|
||||||
<div className="mx-auto mt-12 max-w-screen-lg">
|
<div className="mx-auto mt-12 max-w-screen-lg">
|
||||||
<div className="flex flex-col items-center justify-center">
|
<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" />
|
<FundingRaised className="col-span-12 lg:col-span-6" />
|
||||||
|
|
||||||
<CapTable 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">
|
<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>
|
<h2 className="text-2xl font-bold">Where's the rest?</h2>
|
||||||
|
|||||||
Reference in New Issue
Block a user