Sort repos by activity

This commit is contained in:
Sebastian Martinez
2024-12-05 13:56:12 +01:00
parent 5c8844db1c
commit 653cf9a48d
5 changed files with 9 additions and 8 deletions
@@ -4,5 +4,4 @@ export type ProjectPayloadMeta = {
head: string;
issues: { open: number; closed: number };
patches: { open: number; draft: number; archived: number; merged: number };
lastCommitTimestamp: number;
};
@@ -10,4 +10,5 @@ export type RepoInfo = {
visibility: Visibility;
rid: string;
seeding: number;
lastCommitTimestamp: number;
};
+3 -2
View File
@@ -10,6 +10,7 @@ use crate::cobs::Author;
use crate::error;
#[derive(Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
#[ts(export_to = "repo/")]
pub struct RepoInfo {
@@ -20,6 +21,8 @@ pub struct RepoInfo {
#[ts(as = "String")]
pub rid: identity::RepoId,
pub seeding: usize,
#[ts(type = "number")]
pub last_commit_timestamp: i64,
}
#[derive(Default, Serialize, TS)]
@@ -110,8 +113,6 @@ pub struct ProjectPayloadMeta {
pub issues: issue::IssueCounts,
#[ts(type = "{ open: number, draft: number, archived: number, merged: number }")]
pub patches: patch::PatchCounts,
#[ts(type = "number")]
pub last_commit_timestamp: i64,
}
#[derive(Clone, Serialize, TS, Debug, PartialEq)]
+4 -4
View File
@@ -49,7 +49,7 @@ pub trait Repo: Profile {
entries.push(repo_info)
}
entries.sort_by_key(|repo::RepoInfo { rid, .. }| *rid);
entries.sort_by(|a, b| b.last_commit_timestamp.cmp(&a.last_commit_timestamp));
Ok::<_, Error>(entries)
}
@@ -97,12 +97,12 @@ pub trait Repo: Profile {
.collect::<Vec<_>>();
let db = profile.database()?;
let seeding = db.count(&repo.id).unwrap_or_default();
let (_, head) = repo.head()?;
let commit = repo.commit(head)?;
let project = doc
.payload()
.get(&doc::PayloadId::project())
.and_then(|payload| {
let (_, head) = repo.head().ok()?;
let commit = repo.commit(head).ok()?;
let patches = profile.patches(repo).ok()?;
let patches = patches.counts().ok()?;
let issues = profile.issues(repo).ok()?;
@@ -113,7 +113,6 @@ pub trait Repo: Profile {
issues,
patches,
head,
last_commit_timestamp: commit.time().seconds() * 1000,
};
Some(repo::ProjectPayload::new(data, meta))
@@ -126,6 +125,7 @@ pub trait Repo: Profile {
visibility: doc.visibility().clone().into(),
rid: repo.id,
seeding,
last_commit_timestamp: commit.time().seconds() * 1000,
})
}
+1 -1
View File
@@ -68,7 +68,7 @@
</div>
</div>
<span style:color="var(--color-fill-gray)">
Updated {formatTimestamp(project.meta.lastCommitTimestamp)}
Updated {formatTimestamp(repo.lastCommitTimestamp)}
</span>
</div>
</div>