-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-analytics.ts
More file actions
40 lines (36 loc) · 1.36 KB
/
Copy pathgithub-analytics.ts
File metadata and controls
40 lines (36 loc) · 1.36 KB
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
import { seededRandom, seededRange } from "./seed";
import type { KPI } from "@/types";
/** MOCK_GITHUB_ANALYTICS_DATA - seeded placeholder. A real build calls
* the GitHub REST API (repos, stats/contributors, pulls, issues) server-
* side using GITHUB_TOKEN + GITHUB_ORG from .env - see .env.example. */
export interface RepoStat {
id: string;
repo: string;
stars: number;
forks: number;
openPRs: number;
openIssues: number;
ciStatus: "Passing" | "Failing" | "No runs";
}
const REPOS = ["CeloHT", "celoht-docs", "celoht-brand", "celoht-admin", "celoht-contracts", "celoht-agent-app"];
export function getGithubKpis(): KPI[] {
return [
{ label: "Total Stars", value: 214, format: "number", delta: 18.0 },
{ label: "Contributors", value: 19, format: "number", delta: 5.0 },
{ label: "Open PRs", value: 6, format: "number" },
{ label: "CI Pass Rate", value: 94, format: "percent", delta: 2.0 },
];
}
export function getRepoStats(): RepoStat[] {
const rand = seededRandom(44);
const ci: RepoStat["ciStatus"][] = ["Passing", "Passing", "Passing", "Failing", "No runs"];
return REPOS.map((repo, i) => ({
id: `MOCK-GH-${1400 + i}`,
repo,
stars: seededRange(rand, 4, 90),
forks: seededRange(rand, 0, 22),
openPRs: seededRange(rand, 0, 5),
openIssues: seededRange(rand, 0, 14),
ciStatus: ci[seededRange(rand, 0, 4)]!,
}));
}