From af61dbc1ca2c4babbe96d1b924f799d8a5859255 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 24 May 2018 22:50:18 -0700 Subject: include container_id relation --- rust/src/api_server.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'rust/src/api_server.rs') diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs index 9a2f3b56..8364ec8c 100644 --- a/rust/src/api_server.rs +++ b/rust/src/api_server.rs @@ -303,7 +303,7 @@ impl Server { volume: rev.volume, pages: rev.pages, issue: rev.issue, - container_id: None, // TODO + container_id: rev.container_ident_id.map(|u| u.to_string()), work_id: rev.work_ident_id.to_string(), state: Some(ident.state().unwrap().shortname()), ident: Some(ident.id.to_string()), @@ -339,7 +339,7 @@ impl Server { volume: rev.volume, pages: rev.pages, issue: rev.issue, - container_id: None, // TODO + container_id: rev.container_ident_id.map(|u| u.to_string()), work_id: rev.work_ident_id.to_string(), state: Some(ident.state().unwrap().shortname()), ident: Some(ident.id.to_string()), @@ -639,30 +639,30 @@ impl Api for Server { }; let work_id = uuid::Uuid::parse_str(&body.work_id).expect("invalid UUID"); - let _container_id: Option = match body.container_id { + let container_id: Option = match body.container_id { Some(id) => Some(uuid::Uuid::parse_str(&id).expect("invalid UUID")), None => None, }; let edit: ReleaseEditRow = diesel::sql_query( - "WITH rev AS ( INSERT INTO release_rev (title, release_type, doi, volume, pages, issue, work_ident_id) - VALUES ($1, $2, $3, $4, $5, $6, $7) + "WITH rev AS ( INSERT INTO release_rev (title, release_type, doi, volume, pages, issue, work_ident_id, container_ident_id) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id ), ident AS ( INSERT INTO release_ident (rev_id) VALUES ((SELECT rev.id FROM rev)) RETURNING id ) INSERT INTO release_edit (editgroup_id, ident_id, rev_id) VALUES - ($8, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev)) + ($9, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev)) RETURNING *", ).bind::(body.title) .bind::, _>(body.release_type) - //.bind::, _>(body.date) + //XXX .bind::, _>(body.date) .bind::, _>(body.doi) .bind::, _>(body.volume) .bind::, _>(body.pages) .bind::, _>(body.issue) .bind::(work_id) - //.bind::, _>(body.container_id) + .bind::, _>(container_id) .bind::(editgroup_id) .get_result(&conn) .unwrap(); -- cgit v1.2.3