add dev resources; plumb GUI_ENV_FILE/API_ENV_FILE/API_DESI_DATA into run targets
This commit is contained in:
+24
-30
@@ -1,34 +1,16 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::{
|
||||
extract::Query,
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
extract::{Query, State},
|
||||
Json,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use crate::models::{Catalog, CatalogObject};
|
||||
use crate::store::CatalogStore;
|
||||
|
||||
/// Placeholder catalogs until real DESI EDR/DR1 ingestion lands.
|
||||
static CATALOGS: LazyLock<Vec<Catalog>> = LazyLock::new(|| {
|
||||
vec![
|
||||
Catalog {
|
||||
name: "edr".to_string(),
|
||||
release: "EDR".to_string(),
|
||||
description: "DESI Early Data Release",
|
||||
object_count: None,
|
||||
},
|
||||
Catalog {
|
||||
name: "dr1".to_string(),
|
||||
release: "DR1".to_string(),
|
||||
description: "DESI Data Release 1",
|
||||
object_count: None,
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
pub async fn list_catalogs() -> Json<Vec<Catalog>> {
|
||||
Json(CATALOGS.clone())
|
||||
pub async fn list_catalogs(State(state): State<Arc<CatalogStore>>) -> Json<Vec<Catalog>> {
|
||||
Json(state.catalogs.clone())
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -38,17 +20,29 @@ pub struct ObjectQuery {
|
||||
limit: Option<usize>,
|
||||
}
|
||||
|
||||
/// Placeholder object query. Real implementation will page through the
|
||||
/// centralized DESI catalog store rather than return an empty result set.
|
||||
pub async fn list_objects(Query(query): Query<ObjectQuery>) -> Response {
|
||||
pub async fn list_objects(
|
||||
State(state): State<Arc<CatalogStore>>,
|
||||
Query(query): Query<ObjectQuery>,
|
||||
) -> Json<Vec<CatalogObject>> {
|
||||
let limit = query.limit.unwrap_or(100).min(10_000);
|
||||
|
||||
tracing::debug!(
|
||||
%limit,
|
||||
catalog = query.catalog.as_deref().unwrap_or("all"),
|
||||
"querying catalog objects (placeholder)"
|
||||
objects = state.objects.len(),
|
||||
"querying catalog objects"
|
||||
);
|
||||
|
||||
let objects: Vec<CatalogObject> = Vec::new();
|
||||
(StatusCode::OK, Json(objects)).into_response()
|
||||
let objects: Vec<CatalogObject> = match &query.catalog {
|
||||
Some(catalog) => state
|
||||
.objects
|
||||
.iter()
|
||||
.filter(|o| &o.catalog == catalog)
|
||||
.take(limit)
|
||||
.cloned()
|
||||
.collect(),
|
||||
None => state.objects.iter().take(limit).cloned().collect(),
|
||||
};
|
||||
|
||||
Json(objects)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user