From 39921a6fdf47256b9c2fac67b876795fd0426464 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 14 Aug 2018 17:13:57 -0700 Subject: trivial implementation of core_id field on releases --- rust/fatcat-api/README.md | 2 +- rust/fatcat-api/api.yaml | 3 +++ rust/fatcat-api/api/swagger.yaml | 3 +++ rust/fatcat-api/src/models.rs | 5 +++++ rust/src/api_server.rs | 8 +++++--- rust/src/database_models.rs | 1 + rust/src/database_schema.rs | 1 + rust/tests/test_api_server.rs | 1 + 8 files changed, 20 insertions(+), 4 deletions(-) diff --git a/rust/fatcat-api/README.md b/rust/fatcat-api/README.md index 0a86800f..af4e6a5b 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-07-26T06:49:34.978Z +- Build date: 2018-08-15T00:04:03.771Z 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 fd12d943..7ec91bad 100644 --- a/rust/fatcat-api/api.yaml +++ b/rust/fatcat-api/api.yaml @@ -193,6 +193,9 @@ definitions: isbn13: type: string #format: custom + core_id: + type: string + #format: custom pmid: type: string pmcid: diff --git a/rust/fatcat-api/api/swagger.yaml b/rust/fatcat-api/api/swagger.yaml index 15ebfa81..c572fd29 100644 --- a/rust/fatcat-api/api/swagger.yaml +++ b/rust/fatcat-api/api/swagger.yaml @@ -2239,6 +2239,8 @@ definitions: type: "string" pmid: type: "string" + core_id: + type: "string" isbn13: type: "string" doi: @@ -2359,6 +2361,7 @@ definitions: creator_id: "creator_id" index: 1 pages: "pages" + core_id: "core_id" extra: "{}" editgroup_id: "q3nouwy3nnbsvo3h5klxsx4a7y" state: "wip" diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs index 61812dc2..81701b70 100644 --- a/rust/fatcat-api/src/models.rs +++ b/rust/fatcat-api/src/models.rs @@ -525,6 +525,10 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub pmid: Option, + #[serde(rename = "core_id")] + #[serde(skip_serializing_if = "Option::is_none")] + pub core_id: Option, + #[serde(rename = "isbn13")] #[serde(skip_serializing_if = "Option::is_none")] pub isbn13: Option, @@ -610,6 +614,7 @@ impl ReleaseEntity { wikidata_qid: None, pmcid: None, pmid: None, + core_id: None, isbn13: None, doi: None, release_date: None, diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs index e24b7e39..f7866b68 100644 --- a/rust/src/api_server.rs +++ b/rust/src/api_server.rs @@ -255,6 +255,7 @@ fn release_row2entity( pmid: rev.pmid, pmcid: rev.pmcid, isbn13: rev.isbn13, + core_id: rev.core_id, wikidata_qid: rev.wikidata_qid, volume: rev.volume, issue: rev.issue, @@ -684,14 +685,14 @@ impl Server { }; let edit: ReleaseEditRow = diesel::sql_query( - "WITH rev AS ( INSERT INTO release_rev (title, release_type, release_status, release_date, doi, pmid, pmcid, wikidata_qid, isbn13, volume, issue, pages, work_ident_id, container_ident_id, publisher, language, extra_json) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17) + "WITH rev AS ( INSERT INTO release_rev (title, release_type, release_status, release_date, doi, pmid, pmcid, wikidata_qid, isbn13, core_id, volume, issue, pages, work_ident_id, container_ident_id, publisher, language, extra_json) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18) 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 - ($18, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev)) + ($19, (SELECT ident.id FROM ident), (SELECT rev.id FROM rev)) RETURNING *", ).bind::(entity.title) .bind::, _>(entity.release_type) @@ -703,6 +704,7 @@ impl Server { .bind::, _>(entity.pmcid) .bind::, _>(entity.wikidata_qid) .bind::, _>(entity.isbn13) + .bind::, _>(entity.core_id) .bind::, _>(entity.volume) .bind::, _>(entity.issue) .bind::, _>(entity.pages) diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs index 50176f5f..258bcab7 100644 --- a/rust/src/database_models.rs +++ b/rust/src/database_models.rs @@ -177,6 +177,7 @@ pub struct ReleaseRevRow { pub pmcid: Option, pub wikidata_qid: Option, pub isbn13: Option, + pub core_id: Option, pub volume: Option, pub issue: Option, pub pages: Option, diff --git a/rust/src/database_schema.rs b/rust/src/database_schema.rs index f935302a..3a8fe901 100644 --- a/rust/src/database_schema.rs +++ b/rust/src/database_schema.rs @@ -216,6 +216,7 @@ table! { pmcid -> Nullable, wikidata_qid -> Nullable, isbn13 -> Nullable, + core_id -> Nullable, volume -> Nullable, issue -> Nullable, pages -> Nullable, diff --git a/rust/tests/test_api_server.rs b/rust/tests/test_api_server.rs index ffae8502..02c77413 100644 --- a/rust/tests/test_api_server.rs +++ b/rust/tests/test_api_server.rs @@ -420,6 +420,7 @@ fn test_post_release() { "pmid": "54321", "pmcid": "PMC12345", "wikidata_qid": "Q12345", + "core_id": "7890", "volume": "439", "issue": "IV", "pages": "1-399", -- cgit v1.2.3