refactor: use GitHub activity for project sorting instead of update timestamp

This commit is contained in:
2026-01-13 21:43:45 -06:00
parent bf1bcb736c
commit f79c7711f0
11 changed files with 35 additions and 30 deletions
+5 -1
View File
@@ -48,7 +48,11 @@ pub fn print_project(project: &ApiAdminProject) {
println!(" {} {}", dim.paint("Tags:"), tags.join(", "));
}
println!(" {} {}", dim.paint("Updated:"), project.updated_at);
println!(
" {} {}",
dim.paint("Last Activity:"),
project.last_activity
);
}
/// Print a list of projects in table format
+11 -10
View File
@@ -56,10 +56,8 @@ pub struct ApiAdminProject {
pub demo_url: Option<String>,
#[serde(rename = "createdAt")]
pub created_at: String, // ISO 8601
#[serde(rename = "updatedAt")]
pub updated_at: String, // ISO 8601
#[serde(rename = "lastGithubActivity", skip_serializing_if = "Option::is_none")]
pub last_github_activity: Option<String>, // ISO 8601
#[serde(rename = "lastActivity")]
pub last_activity: String, // ISO 8601
}
impl DbProject {
@@ -91,6 +89,12 @@ impl DbProject {
}
pub fn to_api_admin_project(&self, tags: Vec<DbTag>) -> ApiAdminProject {
let last_activity = self
.last_github_activity
.unwrap_or(self.created_at)
.format(&Rfc3339)
.unwrap();
ApiAdminProject {
project: self.to_api_project(),
tags: tags.into_iter().map(|t| t.to_api_tag()).collect(),
@@ -99,10 +103,7 @@ impl DbProject {
github_repo: self.github_repo.clone(),
demo_url: self.demo_url.clone(),
created_at: self.created_at.format(&Rfc3339).unwrap(),
updated_at: self.updated_at.format(&Rfc3339).unwrap(),
last_github_activity: self
.last_github_activity
.map(|dt| dt.format(&Rfc3339).unwrap()),
last_activity,
}
}
}
@@ -164,7 +165,7 @@ pub async fn get_public_projects(pool: &PgPool) -> Result<Vec<DbProject>, sqlx::
updated_at
FROM projects
WHERE status != 'hidden'
ORDER BY updated_at DESC
ORDER BY COALESCE(last_github_activity, created_at) DESC
"#
)
.fetch_all(pool)
@@ -203,7 +204,7 @@ pub async fn get_all_projects_admin(pool: &PgPool) -> Result<Vec<DbProject>, sql
created_at,
updated_at
FROM projects
ORDER BY updated_at DESC
ORDER BY COALESCE(last_github_activity, created_at) DESC
"#
)
.fetch_all(pool)
+1 -1
View File
@@ -314,7 +314,7 @@ pub async fn get_projects_for_tag(
FROM projects p
JOIN project_tags pt ON p.id = pt.project_id
WHERE pt.tag_id = $1
ORDER BY p.updated_at DESC
ORDER BY COALESCE(p.last_github_activity, p.created_at) DESC
"#,
tag_id
)