diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-08-14 17:13:57 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-08-14 17:13:57 -0700 |
commit | 39921a6fdf47256b9c2fac67b876795fd0426464 (patch) | |
tree | 61c5368a5cfb363a2253d29957f9a9dcfec3835a /rust | |
parent | 2bfb6c54519c3442d663ea41d29f88fb31d96fb4 (diff) | |
download | fatcat-39921a6fdf47256b9c2fac67b876795fd0426464.tar.gz fatcat-39921a6fdf47256b9c2fac67b876795fd0426464.zip |
trivial implementation of core_id field on releases
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 | 3 | ||||
-rw-r--r-- | rust/fatcat-api/src/models.rs | 5 | ||||
-rw-r--r-- | rust/src/api_server.rs | 8 | ||||
-rw-r--r-- | rust/src/database_models.rs | 1 | ||||
-rw-r--r-- | rust/src/database_schema.rs | 1 | ||||
-rw-r--r-- | 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<String>, + #[serde(rename = "core_id")] + #[serde(skip_serializing_if = "Option::is_none")] + pub core_id: Option<String>, + #[serde(rename = "isbn13")] #[serde(skip_serializing_if = "Option::is_none")] pub isbn13: Option<String>, @@ -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::<diesel::sql_types::Text, _>(entity.title) .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.release_type) @@ -703,6 +704,7 @@ impl Server { .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.pmcid) .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.wikidata_qid) .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.isbn13) + .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.core_id) .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.volume) .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(entity.issue) .bind::<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>(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<String>, pub wikidata_qid: Option<String>, pub isbn13: Option<String>, + pub core_id: Option<String>, pub volume: Option<String>, pub issue: Option<String>, pub pages: Option<String>, 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<Text>, wikidata_qid -> Nullable<Text>, isbn13 -> Nullable<Text>, + core_id -> Nullable<Text>, volume -> Nullable<Text>, issue -> Nullable<Text>, pages -> Nullable<Text>, 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", |