Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
remove some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
musitdev committed Feb 22, 2024
1 parent 512fbf3 commit bb5b55e
Showing 1 changed file with 0 additions and 91 deletions.
91 changes: 0 additions & 91 deletions crates/node/src/storage/database/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<Task>> {
// 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<Vec<Task>> {
// 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
Expand Down

0 comments on commit bb5b55e

Please sign in to comment.