mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Consolidate and optimize data fetching for ProjectCard
We consolidate the code that fetches the data for `ProjectCard` in one module, adjacent to the `ProjectCard` component. We also consolidate all the data into one interface to simplify the component API. With the data loading in one place we can eliminate duplicate code and a handful of helper functions. The consolidation also allows us to discover some optimizations to fetching: We parallelize requests and we use the commit detail endpoint instead of the commit list endpoint. For the latter to pay off, we need to deploy caching to the API.
This commit is contained in:
@@ -116,10 +116,3 @@ export async function loadProjectActivity(id: string, baseUrl: BaseUrl) {
|
||||
|
||||
return groupCommitsByWeek(commits.activity);
|
||||
}
|
||||
|
||||
export async function fetchLastCommit(id: string, baseUrl: BaseUrl) {
|
||||
const api = new HttpdClient(baseUrl);
|
||||
const res = await api.project.getAllCommits(id, { perPage: 1 });
|
||||
|
||||
return res.commits[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user