mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-13 15:10:49 +08:00
Sort node projects by HEAD commit time
Instead of going with project activity which is being stripped everything that is older than one year, we should look at the current project head time. Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
@@ -29,6 +29,11 @@
|
||||
const result = await loadProjects(projectPageIndex, baseUrl);
|
||||
projectCount = result.total;
|
||||
projects = [...projects, ...result.projects];
|
||||
projects.sort(
|
||||
(a, b) =>
|
||||
b.latestCommitHeader.committer.time -
|
||||
a.latestCommitHeader.committer.time,
|
||||
);
|
||||
projectPageIndex += 1;
|
||||
} catch (err) {
|
||||
error = err;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { BaseUrl, Project } from "@httpd-client";
|
||||
import type { BaseUrl, CommitHeader, Project } from "@httpd-client";
|
||||
import type { NotFoundRoute } from "@app/lib/router/definitions";
|
||||
import type { WeeklyActivity } from "@app/lib/commit";
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface NodesRouteParams {
|
||||
|
||||
export interface ProjectActivity {
|
||||
project: Project;
|
||||
latestCommitHeader: CommitHeader;
|
||||
activity: WeeklyActivity[];
|
||||
}
|
||||
|
||||
@@ -52,15 +53,22 @@ export async function loadProjects(
|
||||
const results = await Promise.all(
|
||||
projects.map(async project => {
|
||||
const activity = await loadProjectActivity(project.id, baseUrl);
|
||||
const { commit: latestCommitHeader } = await api.project.getCommitBySha(
|
||||
project.id,
|
||||
project.head,
|
||||
);
|
||||
return {
|
||||
project,
|
||||
latestCommitHeader,
|
||||
activity,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
// Sorts projects by most recent commit descending.
|
||||
const sortedProjects = results.sort(
|
||||
(a, b) => b.activity[0]?.time - a.activity[0]?.time,
|
||||
(a, b) =>
|
||||
b.latestCommitHeader.committer.time - a.latestCommitHeader.committer.time,
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user