List scanned flakes
This commit is contained in:
@@ -19,26 +19,19 @@ use axum::{
|
||||
},
|
||||
};
|
||||
use flake_tracker::{
|
||||
storage::{
|
||||
FlakeUri,
|
||||
},
|
||||
templates::{
|
||||
FlakesTemplate,
|
||||
IndexTemplate,
|
||||
},
|
||||
};
|
||||
use sqlx::{
|
||||
FromRow,
|
||||
SqlitePool,
|
||||
sqlite::SqlitePoolOptions,
|
||||
};
|
||||
|
||||
#[derive(FromRow)]
|
||||
struct StorageFlakeRevision {
|
||||
revision_uri: String,
|
||||
uri: Option<String>,
|
||||
nix_store_path: Option<String>,
|
||||
revision: Option<String>,
|
||||
nar_hash: Option<String>,
|
||||
last_modified: Option<i64>,
|
||||
}
|
||||
|
||||
struct AppError(anyhow::Error);
|
||||
|
||||
impl std::fmt::Display for AppError {
|
||||
@@ -121,15 +114,10 @@ async fn route_index(
|
||||
|
||||
async fn route_flakes(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<String, AppError> {
|
||||
let flake_revisions: Vec<StorageFlakeRevision> = sqlx::query_as("
|
||||
) -> Result<impl IntoResponse, AppError> {
|
||||
let flake_revisions: Vec<FlakeUri> = sqlx::query_as("
|
||||
SELECT
|
||||
revision_uri,
|
||||
uri,
|
||||
nix_store_path,
|
||||
revision,
|
||||
nar_hash,
|
||||
last_modified
|
||||
uri
|
||||
FROM flake_revisions
|
||||
GROUP BY uri
|
||||
ORDER BY uri
|
||||
@@ -138,15 +126,7 @@ async fn route_flakes(
|
||||
.await
|
||||
.context("Failed to fetch data from database")?;
|
||||
|
||||
let mut out = String::new();
|
||||
|
||||
for flake_revision in flake_revisions {
|
||||
if let Some(uri) = &flake_revision.uri {
|
||||
out.push_str("- ");
|
||||
out.push_str(&uri);
|
||||
out.push_str("\n");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(out)
|
||||
Ok(render_template(&FlakesTemplate {
|
||||
flakes: flake_revisions,
|
||||
})?)
|
||||
}
|
||||
|
Reference in New Issue
Block a user