mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-10-18 19:10:45 +08:00
Sort repos by activity
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user