mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-18 16:02:10 +00:00
fix audit logs
This commit is contained in:
@@ -25,10 +25,10 @@ pub fn workspaced_service() -> Router {
|
||||
async fn get_audit(
|
||||
authed: ApiAuthed,
|
||||
Extension(user_db): Extension<UserDB>,
|
||||
Path(id): Path<i32>,
|
||||
Path((w_id, id)): Path<(String, i32)>,
|
||||
) -> JsonResult<AuditLog> {
|
||||
let tx = user_db.begin(&authed).await?;
|
||||
let audit = windmill_audit::get_audit(tx, id).await?;
|
||||
let audit = windmill_audit::get_audit(tx, id, &w_id).await?;
|
||||
Ok(Json(audit))
|
||||
}
|
||||
async fn list_audit(
|
||||
|
||||
@@ -152,11 +152,17 @@ pub async fn list_audit(
|
||||
Ok(rows)
|
||||
}
|
||||
|
||||
pub async fn get_audit(mut tx: Transaction<'_, sqlx::Postgres>, id: i32) -> Result<AuditLog> {
|
||||
let audit_o = sqlx::query_as::<_, AuditLog>("SELECT * FROM audit WHERE id = $1")
|
||||
.bind(id)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
pub async fn get_audit(
|
||||
mut tx: Transaction<'_, sqlx::Postgres>,
|
||||
id: i32,
|
||||
w_id: &str,
|
||||
) -> Result<AuditLog> {
|
||||
let audit_o =
|
||||
sqlx::query_as::<_, AuditLog>("SELECT * FROM audit WHERE id = $1 AND workspace_id = $2")
|
||||
.bind(id)
|
||||
.bind(w_id)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
let audit = windmill_common::utils::not_found_if_none(audit_o, "AuditLog", &id.to_string())?;
|
||||
Ok(audit)
|
||||
|
||||
Reference in New Issue
Block a user