Simplify the ProjectCard component

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2023-04-20 14:41:19 +02:00
parent d80c46e085
commit 26419a74e2
6 changed files with 194 additions and 199 deletions
+10 -2
View File
@@ -1,6 +1,7 @@
import type { CommitHeader } from "@httpd-client";
import type { BaseUrl, CommitHeader } from "@httpd-client";
import { getDaysPassed } from "@app/lib/utils";
import { HttpdClient } from "@httpd-client";
// A set of commits grouped by time.
interface CommitGroup {
@@ -70,7 +71,7 @@ export function groupCommits(commits: CommitHeader[]): CommitGroup[] {
}
}
export function groupCommitsByWeek(commits: number[]): WeeklyActivity[] {
function groupCommitsByWeek(commits: number[]): WeeklyActivity[] {
const groupedCommits: WeeklyActivity[] = [];
let groupDate: Date | undefined = undefined;
@@ -114,3 +115,10 @@ export function groupCommitsByWeek(commits: number[]): WeeklyActivity[] {
return groupedCommits;
}
export async function loadProjectActivity(id: string, baseUrl: BaseUrl) {
const api = new HttpdClient(baseUrl);
const commits = await api.project.getActivity(id);
return groupCommitsByWeek(commits.activity);
}