summaryrefslogtreecommitdiffstats
path: root/rust/src
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-25 18:59:02 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-25 18:59:02 -0700
commit6f54d75f644ab5f0120637b1ceb13b16a4c8534d (patch)
treeaa1fb61cb79f8ec69455c31acd8296686f4e7f67 /rust/src
parent79807ca16c98c5f75e08624a514ba2afe585373a (diff)
downloadfatcat-6f54d75f644ab5f0120637b1ceb13b16a4c8534d.tar.gz
fatcat-6f54d75f644ab5f0120637b1ceb13b16a4c8534d.zip
fix date on release
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/api_server.rs13
1 files changed, 6 insertions, 7 deletions
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::<diesel::sql_types::Text, _>(body.title)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(body.release_type)
- //XXX .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(body.date)
+ .bind::<diesel::sql_types::Nullable<diesel::sql_types::Date>, _>(body.date.map(|v| v.naive_utc().date()))
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(body.doi)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(body.volume)
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(body.pages)