From bb5b55e0e8da219961f65ddc4c9dd56952b58a9e Mon Sep 17 00:00:00 2001 From: musitdev Date: Thu, 22 Feb 2024 21:43:24 +0100 Subject: [PATCH] remove some comments --- crates/node/src/storage/database/postgres.rs | 91 -------------------- 1 file changed, 91 deletions(-) diff --git a/crates/node/src/storage/database/postgres.rs b/crates/node/src/storage/database/postgres.rs index b773746c..5209df82 100644 --- a/crates/node/src/storage/database/postgres.rs +++ b/crates/node/src/storage/database/postgres.rs @@ -132,97 +132,6 @@ impl Database { Ok(programs) } - // pub async fn add_task_old(&self, t: &Task) -> Result<()> { - // let mut tx = self.pool.begin().await?; - - // if let Err(err) = sqlx::query( - // "INSERT INTO task ( id, name, args, state, program_id ) VALUES ( $1, $2, $3, $4, $5 )", - // ) - // .bind(t.id) - // .bind(&t.name) - // .bind(&t.args) - // .bind(&t.state) - // .bind(t.program_id) - // .execute(&mut *tx) - // .await - // { - // tx.rollback().await?; - // return Err(err.into()); - // } - - // { - // let mut query_builder = - // sqlx::QueryBuilder::new("INSERT INTO file ( task_id, name, url, checksum )"); - // query_builder.push_values(&t.files, |mut b, new_file| { - // b.push_bind(t.id) - // .push_bind(&new_file.name) - // .push_bind(&new_file.url) - // .push_bind(new_file.checksum); - // }); - - // let query = query_builder.build(); - // if let Err(err) = query.execute(&mut *tx).await { - // tx.rollback().await?; - // return Err(err.into()); - // } - // } - - // tx.commit().await.map_err(|e| e.into()) - // } - - // pub async fn find_task(&self, id: Uuid) -> Result> { - // let mut tx = self.pool.begin().await?; - - // // non-macro query_as used because of sqlx limitations with enums. - // let task = sqlx::query_as::<_, Task>("SELECT * FROM task WHERE id = $1") - // .bind(id) - // .fetch_optional(&mut *tx) - // .await?; - - // // Fetch accompanied Files for the Task. - // match task { - // Some(mut task) => { - // let mut files = - // sqlx::query_as::<_, DbFile>("SELECT * FROM file WHERE task_id = $1") - // .bind(id) - // .fetch_all(&mut *tx) - // .await?; - // task.files.append(&mut files); - // Ok(Some(task)) - // } - // None => Ok(None), - // } - // } - - // pub async fn get_tasks(&self) -> Result> { - // let mut tx = self.pool.begin().await?; - - // // non-macro query_as used because of sqlx limitations with enums. - // let mut tasks = sqlx::query_as::<_, Task>("SELECT * FROM task") - // .fetch_all(&mut *tx) - // .await?; - - // for task in &mut tasks { - // let mut files = sqlx::query_as::<_, DbFile>("SELECT * FROM file WHERE task_id = $1") - // .bind(task.id) - // .fetch_all(&mut *tx) - // .await?; - - // task.files.append(&mut files); - // } - - // Ok(tasks) - // } - - // pub async fn update_task_state(&self, t: &Task) -> Result<()> { - // sqlx::query("UPDATE task SET state = $1 WHERE id = $2") - // .bind(&t.state) - // .bind(t.id) - // .execute(&self.pool) - // .await?; - // Ok(()) - // } - // NOTE: There are plenty of opportunities for optimizations in following // transaction related operations. They are implemented naively on purpose // for now to maintain initial flexibility in development. Later on, these