Skip to content

Commit

Permalink
Merge pull request #673 from runcom/mfcg-export-ovs
Browse files Browse the repository at this point in the history
feat(manufacturing-server): implement an export OVs endpoint
  • Loading branch information
runcom authored Sep 25, 2024
2 parents 95af64f + 0f3d464 commit b775d03
Show file tree
Hide file tree
Showing 11 changed files with 358 additions and 17 deletions.
127 changes: 117 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ where
/// Gets an OV
fn get_ov(guid: &str, conn: &mut T) -> Result<OwnerOV>;

/// Returns all the OVs in the DB
fn get_all_ovs(conn: &mut T) -> Result<Vec<OwnerOV>>;

/// Deletes an OV
fn delete_ov(guid: &str, conn: &mut T) -> Result<()>;

Expand Down Expand Up @@ -101,6 +104,9 @@ where
/// Gets an OV
fn get_ov(guid: &str, conn: &mut T) -> Result<RendezvousOV>;

/// Returns all the OVs in the DB
fn get_all_ovs(conn: &mut T) -> Result<Vec<RendezvousOV>>;

/// Deletes an OV
fn delete_ov(guid: &str, conn: &mut T) -> Result<()>;

Expand Down
14 changes: 14 additions & 0 deletions db/src/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ impl DBStoreOwner<PgConnection> for PostgresOwnerDB {
Ok(result)
}

fn get_all_ovs(conn: &mut PgConnection) -> Result<Vec<OwnerOV>> {
let result = super::schema::owner_vouchers::dsl::owner_vouchers
.select(OwnerOV::as_select())
.load(conn)?;
Ok(result)
}

fn delete_ov(guid: &str, conn: &mut PgConnection) -> Result<()> {
diesel::delete(owner_vouchers::dsl::owner_vouchers)
.filter(super::schema::owner_vouchers::guid.eq(guid))
Expand Down Expand Up @@ -222,6 +229,13 @@ impl DBStoreRendezvous<PgConnection> for PostgresRendezvousDB {
Ok(result)
}

fn get_all_ovs(conn: &mut PgConnection) -> Result<Vec<RendezvousOV>> {
let result = super::schema::rendezvous_vouchers::dsl::rendezvous_vouchers
.select(RendezvousOV::as_select())
.load(conn)?;
Ok(result)
}

fn delete_ov(guid: &str, conn: &mut PgConnection) -> Result<()> {
diesel::delete(rendezvous_vouchers::dsl::rendezvous_vouchers)
.filter(super::schema::rendezvous_vouchers::guid.eq(guid))
Expand Down
14 changes: 14 additions & 0 deletions db/src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ impl DBStoreOwner<SqliteConnection> for SqliteOwnerDB {
Ok(result)
}

fn get_all_ovs(conn: &mut SqliteConnection) -> Result<Vec<OwnerOV>> {
let result = super::schema::owner_vouchers::dsl::owner_vouchers
.select(OwnerOV::as_select())
.load(conn)?;
Ok(result)
}

fn delete_ov(guid: &str, conn: &mut SqliteConnection) -> Result<()> {
diesel::delete(owner_vouchers::dsl::owner_vouchers)
.filter(super::schema::owner_vouchers::guid.eq(guid))
Expand Down Expand Up @@ -224,6 +231,13 @@ impl DBStoreRendezvous<SqliteConnection> for SqliteRendezvousDB {
Ok(result)
}

fn get_all_ovs(conn: &mut SqliteConnection) -> Result<Vec<RendezvousOV>> {
let result = super::schema::rendezvous_vouchers::dsl::rendezvous_vouchers
.select(RendezvousOV::as_select())
.load(conn)?;
Ok(result)
}

fn delete_ov(guid: &str, conn: &mut SqliteConnection) -> Result<()> {
diesel::delete(rendezvous_vouchers::dsl::rendezvous_vouchers)
.filter(super::schema::rendezvous_vouchers::guid.eq(guid))
Expand Down
3 changes: 3 additions & 0 deletions manufacturing-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ warp = "0.3.6"
log = "0.4"
hex = "0.4"
serde_yaml = "0.9"
tar = "0.4.41"
flate2 = "1.0.31"
tempdir = "0.3.7"

fdo-data-formats = { path = "../data-formats", version = "0.5.0" }
fdo-http-wrapper = { path = "../http-wrapper", version = "0.5.0", features = ["server"] }
Expand Down
Loading

0 comments on commit b775d03

Please sign in to comment.