Add project stats

This commit is contained in:
Alexis Sellier
2021-06-14 14:37:50 +02:00
parent 15545fdee8
commit 77c1d0abef
2 changed files with 42 additions and 20 deletions
+27 -11
View File
@@ -30,33 +30,37 @@
<style>
main > header {
font-size: 0.75rem;
padding: 0 8rem;
margin-bottom: 2rem;
display: flex;
align-items: center;
justify-content: left;
}
.commit {
display: inline-block;
font-size: 0.75rem;
font-family: var(--font-family-monospace);
color: var(--color-secondary);
background-color: var(--color-secondary-background);
padding: 0.75rem;
main > header > * {
margin-right: 0.75rem;
border-radius: 0.25rem;
min-width: max-content;
}
.commit {
display: inline-block;
font-family: var(--font-family-monospace);
color: var(--color-secondary);
background-color: var(--color-secondary-background);
padding: 0.75rem;
}
.anchor {
display: flex;
margin-left: 0.75rem;
min-width: max-content;
}
.anchor-widget {
display: flex;
padding: 0.75rem;
border-radius: 0.25rem;
color: var(--color-tertiary);
background-color: var(--color-tertiary-background);
font-size: 0.75rem;
border-radius: 0.25rem;
}
.anchor-widget.not-anchored {
color: var(--color-foreground-faded);
@@ -70,6 +74,12 @@
margin-right: 0;
}
.stat {
font-family: var(--font-family-monospace);
padding: 0.75rem;
background: var(--color-foreground-background);
}
.center-content {
margin: 0 auto;
max-width: var(--content-max-width);
@@ -124,6 +134,12 @@
<div class="commit">
commit {commit}
</div>
<div class="stat">
<strong>{tree.stats.commits}</strong> commits
</div>
<div class="stat">
<strong>{tree.stats.contributors}</strong> contributors
</div>
<div class="anchor">
{#if org}
{#await getAnchor}
+15 -9
View File
@@ -21,6 +21,18 @@ export interface Meta {
maintainers: Urn[];
}
export interface Tree {
path: string;
info: EntryInfo;
entries: Array<Entry>;
stats: Stats;
}
export interface Stats {
commits: number;
contributors: number;
}
export interface Author {
avatar: string;
email: string;
@@ -41,7 +53,7 @@ export interface CommitHeader {
summary: string;
}
export interface Info {
export interface EntryInfo {
name: string;
objectType: ObjectType;
lastCommit: CommitHeader;
@@ -49,7 +61,7 @@ export interface Info {
export interface Entry {
path: string;
info: Info;
info: EntryInfo;
}
export interface Blob {
@@ -60,12 +72,6 @@ export interface Blob {
info: Info;
}
export interface Tree {
entries: Entry[];
info: Info;
path: string;
}
export async function getInfo(urn: string, config: Config): Promise<Info> {
return api.get(`projects/${urn}`, {}, config);
}
@@ -75,7 +81,7 @@ export async function getTree(
commit: string,
path: string,
config: Config
): Promise<any> {
): Promise<Tree> {
if (path === "/") {
path = "";
}