Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
feat: summary stats on repo report
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Jul 10, 2024
1 parent d756ec0 commit cf7f0ba
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/app/repo/status/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import Heading from "@/components/Heading";
import List from "@/components/List";
import checks from "@/utils/checks/index";
import Stats from "@/components/Stats";

const repo = {
id: 405139301,
Expand Down Expand Up @@ -210,7 +211,14 @@ export default function Page() {
{ icon: TicketIcon, text: repo.open_issues },
]}
/>
<List data={results} />
<Stats
data={[
{ name: "Success", stat: results.summary.success?.length || 0 },
{ name: "Warning", stat: results.summary.warning?.length || 0 },
{ name: "Error", stat: results.summary.error?.length || 0 },
]}
/>
<List data={results.checks} />
</>
);
}
2 changes: 1 addition & 1 deletion src/components/Heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Link from "next/link";

export default function Heading({ title, actions = [], extras = [] }) {
return (
<div className="lg:flex lg:items-center lg:justify-between mt-4 mb-12">
<div className="lg:flex lg:items-center lg:justify-between mt-4">
<div className="min-w-0 flex-1">
<h2 className="text-2xl font-bold leading-7 text-white sm:truncate sm:text-3xl sm:tracking-tight">
{title}
Expand Down
24 changes: 24 additions & 0 deletions src/components/Stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export default function Stats({ data }) {
return (
<div>
<h3 className="text-base font-semibold leading-6 text-gray-900">
Last 30 days
</h3>
<dl className="mt-5 grid grid-cols-1 gap-5 sm:grid-cols-3">
{data.map((item) => (
<div
key={item.name}
className="overflow-hidden rounded-lg bg-white px-4 py-5 shadow sm:p-6"
>
<dt className="truncate text-sm font-medium text-gray-500">
{item.name}
</dt>
<dd className="mt-1 text-3xl font-semibold tracking-tight text-gray-900">
{item.stat}
</dd>
</div>
))}
</dl>
</div>
);
}
4 changes: 3 additions & 1 deletion src/utils/checks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ import url from "./url";
export default function checks(repo) {
const checks = [description(repo), url(repo), topics(repo), activity(repo)];

return checks;
const summary = Object.groupBy(checks, ({ status }) => status);

return { checks, summary };
}

0 comments on commit cf7f0ba

Please sign in to comment.