From 6f54d75f644ab5f0120637b1ceb13b16a4c8534d Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 25 May 2018 18:59:02 -0700 Subject: fix date on release --- rust/src/api_server.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'rust/src') diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs index 6fbce00b..b29dae69 100644 --- a/rust/src/api_server.rs +++ b/rust/src/api_server.rs @@ -342,7 +342,7 @@ impl Server { let entity = ReleaseEntity { title: rev.title, release_type: rev.release_type, - // XXX: date: rev.date, + date: rev.date.map(|v| chrono::DateTime::from_utc(v.and_hms(0, 0, 0), chrono::Utc)), doi: rev.doi, volume: rev.volume, pages: rev.pages, @@ -405,7 +405,7 @@ impl Server { let entity = ReleaseEntity { title: rev.title, release_type: rev.release_type, - // XXX: date: rev.date, + date: rev.date.map(|v| chrono::DateTime::from_utc(v.and_hms(0, 0, 0), chrono::Utc)), doi: rev.doi, volume: rev.volume, pages: rev.pages, @@ -740,20 +740,19 @@ impl Api for Server { None => None, }; - println!("{:?}", container_id); let edit: ReleaseEditRow = diesel::sql_query( - "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) + "WITH rev AS ( INSERT INTO release_rev (title, release_type, date, doi, volume, pages, issue, work_ident_id, container_ident_id) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) 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 - ($9, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev)) + ($10, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev)) RETURNING *", ).bind::(body.title) .bind::, _>(body.release_type) - //XXX .bind::, _>(body.date) + .bind::, _>(body.date.map(|v| v.naive_utc().date())) .bind::, _>(body.doi) .bind::, _>(body.volume) .bind::, _>(body.pages) -- cgit v1.2.3