Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 6cbc60e

Browse files
committed
Add api_changes_resolve_change
1 parent b2640d3 commit 6cbc60e

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/changes.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,32 @@ async fn api_changes_lock_change(change_id: i64, lock_number: i64, api_token: Qx
236236
}
237237
}
238238

239+
#[get("/api/event/current/changes/resolve-change?<change_id>&<lock_number>&<accepted>&<status_message>")]
240+
async fn api_changes_resolve_change(
241+
change_id: i64,
242+
lock_number: i64,
243+
accepted: bool,
244+
status_message: Option<String>,
245+
api_token: QxApiToken,
246+
state: &State<SharedQxState>,
247+
db: &State<DbPool>
248+
) -> Result<(), Custom<String>> {
249+
let new_status = if accepted {
250+
ChangeStatus::Accepted
251+
} else {
252+
ChangeStatus::Rejected
253+
};
254+
let event = load_event_info_for_api_token(&api_token, db).await?;
255+
let edb = get_event_db(event.id, state).await.map_err(anyhow_to_custom_error)?;
256+
sqlx::query("UPDATE changes SET status=?, status_message=? WHERE id=? AND lock_number=?")
257+
.bind(format!("{new_status}"))
258+
.bind(status_message)
259+
.bind(change_id)
260+
.bind(lock_number)
261+
.execute(&edb).await.map_err(sqlx_to_custom_error)?;
262+
Ok(())
263+
}
264+
239265
#[post("/api/event/current/changes/run-updated?<run_id>", data = "<change>")]
240266
async fn add_run_updated_change(run_id: DataId, change: Json<Option<RunChange>>, api_token: QxApiToken, state: &State<SharedQxState>, db: &State<DbPool>) -> Result<(), Custom<String>> {
241267
let event = load_event_info_for_api_token(&api_token, db).await?;
@@ -421,5 +447,6 @@ pub fn extend(rocket: Rocket<Build>) -> Rocket<Build> {
421447
api_changes_get,
422448
api_changes_delete,
423449
api_changes_lock_change,
450+
api_changes_resolve_change,
424451
])
425452
}

0 commit comments

Comments
 (0)