diff options
Diffstat (limited to 'rust')
-rw-r--r-- | rust/fatcat-api/README.md | 2 | ||||
-rw-r--r-- | rust/fatcat-api/api.yaml | 3 | ||||
-rw-r--r-- | rust/fatcat-api/api/swagger.yaml | 4 | ||||
-rw-r--r-- | rust/fatcat-api/src/models.rs | 5 | ||||
-rw-r--r-- | rust/fatcat-openapi2.yml | 3 | ||||
-rw-r--r-- | rust/src/api_server.rs | 13 |
6 files changed, 20 insertions, 10 deletions
diff --git a/rust/fatcat-api/README.md b/rust/fatcat-api/README.md index b67ad8f1..364f7271 100644 --- a/rust/fatcat-api/README.md +++ b/rust/fatcat-api/README.md @@ -13,7 +13,7 @@ To see how to make this your own, look here: [README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) - API version: 0.1.0 -- Build date: 2018-05-26T00:48:55.047Z +- Build date: 2018-05-26T01:47:28.955Z This autogenerated project defines an API crate `fatcat` which contains: * An `Api` trait defining the API in Rust. diff --git a/rust/fatcat-api/api.yaml b/rust/fatcat-api/api.yaml index 8dd4177f..cfce24d7 100644 --- a/rust/fatcat-api/api.yaml +++ b/rust/fatcat-api/api.yaml @@ -145,7 +145,8 @@ definitions: type: string example: "preprint" date: - type: date + type: string + format: date doi: type: string #format: custom diff --git a/rust/fatcat-api/api/swagger.yaml b/rust/fatcat-api/api/swagger.yaml index ce85d813..506cb9db 100644 --- a/rust/fatcat-api/api/swagger.yaml +++ b/rust/fatcat-api/api/swagger.yaml @@ -1191,6 +1191,9 @@ definitions: doi: type: "string" example: "10.1234/abcde.789" + date: + type: "string" + format: "date" release_type: type: "string" example: "preprint" @@ -1226,6 +1229,7 @@ definitions: extra: type: "object" example: + date: "2000-01-23" redirect: "f1f046a3-45c9-4b99-adce-000000000002" work_id: "f1f046a3-45c9-4b99-adce-000000000001" issue: "12" diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs index 8d3abe7d..e3ce33c3 100644 --- a/rust/fatcat-api/src/models.rs +++ b/rust/fatcat-api/src/models.rs @@ -442,6 +442,10 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub doi: Option<String>, + #[serde(rename = "date")] + #[serde(skip_serializing_if = "Option::is_none")] + pub date: Option<chrono::DateTime<chrono::Utc>>, + #[serde(rename = "release_type")] #[serde(skip_serializing_if = "Option::is_none")] pub release_type: Option<String>, @@ -491,6 +495,7 @@ impl ReleaseEntity { pages: None, volume: None, doi: None, + date: None, release_type: None, container_id: None, work_id: work_id, diff --git a/rust/fatcat-openapi2.yml b/rust/fatcat-openapi2.yml index 8dd4177f..cfce24d7 100644 --- a/rust/fatcat-openapi2.yml +++ b/rust/fatcat-openapi2.yml @@ -145,7 +145,8 @@ definitions: type: string example: "preprint" date: - type: date + type: string + format: date doi: type: string #format: custom 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) |