fmt: apply cargo fmt to missions
This commit is contained in:
@@ -6,10 +6,12 @@
|
|||||||
//! `/api/loops/*` surfaces stay live in parallel until Slice 9.
|
//! `/api/loops/*` surfaces stay live in parallel until Slice 9.
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
Json,
|
|
||||||
extract::{Path, Query, State},
|
extract::{Path, Query, State},
|
||||||
|
Json,
|
||||||
|
};
|
||||||
|
use cm_db::repo::missions::{
|
||||||
|
Mission, MissionArtifact, MissionPhase, MissionTask, NewMission, NewMissionPhase,
|
||||||
};
|
};
|
||||||
use cm_db::repo::missions::{Mission, MissionArtifact, MissionPhase, MissionTask, NewMission, NewMissionPhase};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
@@ -151,12 +153,7 @@ pub async fn set_status(
|
|||||||
if !allowed.contains(&body.status.as_str()) {
|
if !allowed.contains(&body.status.as_str()) {
|
||||||
return Err(ApiError::BadRequest);
|
return Err(ApiError::BadRequest);
|
||||||
}
|
}
|
||||||
cm_db::repo::missions::set_status(
|
cm_db::repo::missions::set_status(&state.pool, id, user.workspace_id.as_uuid(), &body.status)
|
||||||
&state.pool,
|
|
||||||
id,
|
|
||||||
user.workspace_id.as_uuid(),
|
|
||||||
&body.status,
|
|
||||||
)
|
|
||||||
.await?;
|
.await?;
|
||||||
let mission = cm_db::repo::missions::get(&state.pool, id, user.workspace_id.as_uuid())
|
let mission = cm_db::repo::missions::get(&state.pool, id, user.workspace_id.as_uuid())
|
||||||
.await?
|
.await?
|
||||||
|
|||||||
@@ -164,11 +164,7 @@ pub async fn insert(pool: &PgPool, m: NewMission<'_>) -> Result<Uuid, DbError> {
|
|||||||
|
|
||||||
/// Workspace-scoped fetch — returns None when the id belongs to a
|
/// Workspace-scoped fetch — returns None when the id belongs to a
|
||||||
/// different workspace so callers can't leak cross-workspace metadata.
|
/// different workspace so callers can't leak cross-workspace metadata.
|
||||||
pub async fn get(
|
pub async fn get(pool: &PgPool, id: Uuid, workspace_id: Uuid) -> Result<Option<Mission>, DbError> {
|
||||||
pool: &PgPool,
|
|
||||||
id: Uuid,
|
|
||||||
workspace_id: Uuid,
|
|
||||||
) -> Result<Option<Mission>, DbError> {
|
|
||||||
use sqlx::Row;
|
use sqlx::Row;
|
||||||
let row = sqlx::query(
|
let row = sqlx::query(
|
||||||
"SELECT id, workspace_id, title, template_kind, team_id,
|
"SELECT id, workspace_id, title, template_kind, team_id,
|
||||||
@@ -288,11 +284,7 @@ pub async fn phases_for(pool: &PgPool, mission_id: Uuid) -> Result<Vec<MissionPh
|
|||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_phase_status(
|
pub async fn set_phase_status(pool: &PgPool, phase_id: Uuid, status: &str) -> Result<(), DbError> {
|
||||||
pool: &PgPool,
|
|
||||||
phase_id: Uuid,
|
|
||||||
status: &str,
|
|
||||||
) -> Result<(), DbError> {
|
|
||||||
let is_start = status == "running";
|
let is_start = status == "running";
|
||||||
let is_end = matches!(status, "completed" | "failed" | "skipped");
|
let is_end = matches!(status, "completed" | "failed" | "skipped");
|
||||||
sqlx::query(
|
sqlx::query(
|
||||||
@@ -409,10 +401,7 @@ pub struct RegisterArtifact<'a> {
|
|||||||
|
|
||||||
/// Register an artifact discovered on disk (or produced inline).
|
/// Register an artifact discovered on disk (or produced inline).
|
||||||
/// Idempotent on (mission_id, path).
|
/// Idempotent on (mission_id, path).
|
||||||
pub async fn register_artifact(
|
pub async fn register_artifact(pool: &PgPool, a: RegisterArtifact<'_>) -> Result<Uuid, DbError> {
|
||||||
pool: &PgPool,
|
|
||||||
a: RegisterArtifact<'_>,
|
|
||||||
) -> Result<Uuid, DbError> {
|
|
||||||
use sqlx::Row;
|
use sqlx::Row;
|
||||||
let render_status = if a.render_pdf { "pending" } else { "skip" };
|
let render_status = if a.render_pdf { "pending" } else { "skip" };
|
||||||
let row = sqlx::query(
|
let row = sqlx::query(
|
||||||
@@ -482,10 +471,7 @@ pub async fn artifacts_for(
|
|||||||
/// PDF renderer worker (Slice 6) picks a pending artifact off the
|
/// PDF renderer worker (Slice 6) picks a pending artifact off the
|
||||||
/// queue. Skips the FOR UPDATE dance until we see concurrent renderers
|
/// queue. Skips the FOR UPDATE dance until we see concurrent renderers
|
||||||
/// — one renderer per process is fine for the first cut.
|
/// — one renderer per process is fine for the first cut.
|
||||||
pub async fn next_pdf_pending(
|
pub async fn next_pdf_pending(pool: &PgPool, limit: i64) -> Result<Vec<MissionArtifact>, DbError> {
|
||||||
pool: &PgPool,
|
|
||||||
limit: i64,
|
|
||||||
) -> Result<Vec<MissionArtifact>, DbError> {
|
|
||||||
use sqlx::Row;
|
use sqlx::Row;
|
||||||
let rows = sqlx::query(
|
let rows = sqlx::query(
|
||||||
"SELECT id, mission_id, phase_id, path, kind, mime,
|
"SELECT id, mission_id, phase_id, path, kind, mime,
|
||||||
|
|||||||
Reference in New Issue
Block a user