MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / context

Function context

src/dashboard/projects.rs:166–203  ·  view source on GitHub ↗
(
    State(runtime): State<DashboardRuntime>,
    AxumPath(project_id): AxumPath<String>,
)

Source from the content-addressed store, hash-verified

164}
165
166pub(crate) async fn context(
167 State(runtime): State<DashboardRuntime>,
168 AxumPath(project_id): AxumPath<String>,
169) -> (StatusCode, Json<Value>) {
170 let Some(db) = GlobalDb::open().await else {
171 return (
172 StatusCode::SERVICE_UNAVAILABLE,
173 Json(json!({
174 "status": "missing_registry",
175 "project": null,
176 "aliases": [],
177 "stores": [],
178 })),
179 );
180 };
181 let Some(context) = db.project_registry_context_by_id(&project_id).await else {
182 return (
183 StatusCode::NOT_FOUND,
184 Json(json!({
185 "status": "not_found",
186 "project": null,
187 "aliases": [],
188 "stores": [],
189 })),
190 );
191 };
192 let is_active = Some(project_id.as_str()) == runtime.active_project_id();
193 (
194 StatusCode::OK,
195 Json(json!({
196 "status": "ok",
197 "is_active": is_active,
198 "project": context.project,
199 "aliases": context.aliases,
200 "stores": context.stores,
201 })),
202 )
203}
204
205#[cfg(test)]
206mod tests {

Callers

nothing calls this directly

Calls 3

active_project_idMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected