CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | /**
* Block J12 — Community profile / health scorecard route.
*
* GET /:owner/:repo/community
*
* Renders GitHub-parity "Community standards" checklist: README, LICENSE,
* CODE_OF_CONDUCT, CONTRIBUTING, issue + PR templates, description, topics.
* Scored in percentage and broken down by required vs recommended.
*
* Never 500s — falls back to a zero-score report when git or DB reads fail.
*/
import { Hono } from "hono";
import { and, eq } from "drizzle-orm";
import { db } from "../db";
import { repositories, repoTopics, users } from "../db/schema";
import { Layout } from "../views/layout";
import { RepoHeader, RepoNav } from "../views/components";
import { softAuth } from "../middleware/auth";
import type { AuthEnv } from "../middleware/auth";
import { computeHealth, type HealthReport } from "../lib/community";
import { getUnreadCount } from "../lib/unread";
const community = new Hono<AuthEnv>();
community.get("/:owner/:repo/community", softAuth, async (c) => {
const user = c.get("user");
const { owner: ownerName, repo: repoName } = c.req.param();
let repoRow: {
id: string;
description: string | null;
starCount: number;
forkCount: number;
} | null = null;
try {
const rows = await db
.select({
id: repositories.id,
description: repositories.description,
starCount: repositories.starCount,
forkCount: repositories.forkCount,
})
.from(repositories)
.innerJoin(users, eq(repositories.ownerId, users.id))
.where(
and(
eq(users.username, ownerName),
eq(repositories.name, repoName)
)
)
.limit(1);
repoRow = rows[0] || null;
} catch {
repoRow = null;
}
if (!repoRow) return c.notFound();
let topics: string[] = [];
try {
const rows = await db
.select({ topic: repoTopics.topic })
.from(repoTopics)
.where(eq(repoTopics.repositoryId, repoRow.id));
topics = rows.map((r) => r.topic);
} catch {
topics = [];
}
const report: HealthReport = await computeHealth({
owner: ownerName,
repo: repoName,
description: repoRow.description,
topics,
});
const unread = user ? await getUnreadCount(user.id) : 0;
const barColor =
report.score >= 80
? "var(--green)"
: report.score >= 50
? "var(--yellow)"
: "var(--red)";
return c.html(
<Layout
title={`Community standards — ${ownerName}/${repoName}`}
user={user}
notificationCount={unread}
>
<RepoHeader
owner={ownerName}
repo={repoName}
starCount={repoRow.starCount}
forkCount={repoRow.forkCount}
currentUser={user?.username || null}
/>
<RepoNav owner={ownerName} repo={repoName} active="insights" />
<h2>Community standards</h2>
<p style="color: var(--text-muted); max-width: 640px">
Healthy projects set expectations and onboard new contributors. Here's
how this repo scores on GlueCron's community profile checklist.
</p>
<div
style="margin: 16px 0 24px; padding: 16px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius)"
data-testid="community-score"
>
<div style="display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px">
<strong style="font-size: 18px">{report.score}%</strong>
<span style="color: var(--text-muted); font-size: 13px">
{report.passed} of {report.total} items present · {report.requiredPassed}/{report.requiredTotal} required
</span>
</div>
<div style="height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden">
<div
style={`width: ${report.score}%; height: 100%; background: ${barColor}; transition: width 0.3s`}
/>
</div>
<div style="margin-top: 8px; font-size: 12px; color: var(--text-muted)">
{report.meetsRequired
? "All required items present — nice work."
: "Add the required items to reach the minimum community profile."}
</div>
</div>
<ul style="list-style: none; padding: 0; margin: 0">
{report.items.map((item) => (
<li
style="display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border)"
data-testid={`community-item-${item.key}`}
>
<span
style={`font-size: 20px; color: ${item.present ? "var(--green)" : item.required ? "var(--red)" : "var(--text-muted)"}; line-height: 1`}
aria-label={item.present ? "present" : "missing"}
>
{item.present ? "\u2713" : item.required ? "\u2717" : "\u25CB"}
</span>
<div style="flex: 1">
<div style="display: flex; align-items: center; gap: 8px">
<strong>{item.label}</strong>
{item.required && (
<span
style="font-size: 10px; padding: 1px 6px; border-radius: 10px; background: rgba(248, 81, 73, 0.1); color: var(--red); text-transform: uppercase; letter-spacing: 0.5px"
>
Required
</span>
)}
</div>
<div style="color: var(--text-muted); font-size: 13px; margin-top: 2px">
{item.description}
</div>
{!item.present && item.suggestedPath && (
<div style="margin-top: 6px">
<a
href={`/${ownerName}/${repoName}/new/main?path=${encodeURIComponent(item.suggestedPath)}`}
class="btn"
style="font-size: 12px; padding: 4px 10px"
>
Add {item.suggestedPath}
</a>
</div>
)}
{!item.present && item.key === "description" && (
<div style="margin-top: 6px">
<a
href={`/${ownerName}/${repoName}/settings`}
class="btn"
style="font-size: 12px; padding: 4px 10px"
>
Edit description
</a>
</div>
)}
{!item.present && item.key === "topics" && (
<div style="margin-top: 6px">
<a
href={`/${ownerName}/${repoName}/settings`}
class="btn"
style="font-size: 12px; padding: 4px 10px"
>
Add topics
</a>
</div>
)}
</div>
</li>
))}
</ul>
</Layout>
);
});
export default community;
|