aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-21 12:23:08 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-21 12:23:08 -0800
commit2027162f9871ebe43a40b0ac4615149141b7a571 (patch)
treec75087fa12c9841a4f12d66fc1b2770e9c6847c4 /rust/src
parentbdb1e6c42317c8ea9d2152896e308203ecd3ac3e (diff)
downloadfatcat-2027162f9871ebe43a40b0ac4615149141b7a571.tar.gz
fatcat-2027162f9871ebe43a40b0ac4615149141b7a571.zip
allow arxiv and jstor lookups
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/endpoint_handlers.rs34
-rw-r--r--rust/src/endpoints.rs4
2 files changed, 31 insertions, 7 deletions
diff --git a/rust/src/endpoint_handlers.rs b/rust/src/endpoint_handlers.rs
index bc606af9..4567e810 100644
--- a/rust/src/endpoint_handlers.rs
+++ b/rust/src/endpoint_handlers.rs
@@ -259,12 +259,14 @@ impl Server {
pmid: &Option<String>,
pmcid: &Option<String>,
core_id: &Option<String>,
+ arxiv_id: &Option<String>,
+ jstor_id: &Option<String>,
expand_flags: ExpandFlags,
hide_flags: HideFlags,
) -> Result<ReleaseEntity> {
let (ident, rev): (ReleaseIdentRow, ReleaseRevRow) =
- match (doi, wikidata_qid, isbn13, pmid, pmcid, core_id) {
- (Some(doi), None, None, None, None, None) => {
+ match (doi, wikidata_qid, isbn13, pmid, pmcid, core_id, arxiv_id, jstor_id) {
+ (Some(doi), None, None, None, None, None, None, None) => {
check_doi(doi)?;
release_ident::table
.inner_join(release_rev::table)
@@ -273,7 +275,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, Some(wikidata_qid), None, None, None, None) => {
+ (None, Some(wikidata_qid), None, None, None, None, None, None) => {
check_wikidata_qid(wikidata_qid)?;
release_ident::table
.inner_join(release_rev::table)
@@ -282,7 +284,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, None, Some(isbn13), None, None, None) => {
+ (None, None, Some(isbn13), None, None, None, None, None) => {
// TODO: check_isbn13(isbn13)?;
release_ident::table
.inner_join(release_rev::table)
@@ -291,7 +293,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, None, None, Some(pmid), None, None) => {
+ (None, None, None, Some(pmid), None, None, None, None) => {
check_pmid(pmid)?;
release_ident::table
.inner_join(release_rev::table)
@@ -300,7 +302,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, None, None, None, Some(pmcid), None) => {
+ (None, None, None, None, Some(pmcid), None, None, None) => {
check_pmcid(pmcid)?;
release_ident::table
.inner_join(release_rev::table)
@@ -309,7 +311,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, None, None, None, None, Some(core_id)) => {
+ (None, None, None, None, None, Some(core_id), None, None) => {
// TODO: check_core_id(core_id)?;
release_ident::table
.inner_join(release_rev::table)
@@ -318,6 +320,24 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
+ (None, None, None, None, None, None, Some(arxiv_id), None) => {
+ // TODO: check_arxiv_id(arxiv_id)?;
+ release_ident::table
+ .inner_join(release_rev::table)
+ .filter(release_rev::arxiv_id.eq(arxiv_id))
+ .filter(release_ident::is_live.eq(true))
+ .filter(release_ident::redirect_id.is_null())
+ .first(conn)?
+ }
+ (None, None, None, None, None, None, None, Some(jstor_id)) => {
+ // TODO: check_jstor_id(jstor_id)?;
+ release_ident::table
+ .inner_join(release_rev::table)
+ .filter(release_rev::jstor_id.eq(jstor_id))
+ .filter(release_ident::is_live.eq(true))
+ .filter(release_ident::redirect_id.is_null())
+ .first(conn)?
+ }
_ => {
return Err(
FatcatError::MissingOrMultipleExternalId("in lookup".to_string()).into(),
diff --git a/rust/src/endpoints.rs b/rust/src/endpoints.rs
index 670c7fd9..8c45ea75 100644
--- a/rust/src/endpoints.rs
+++ b/rust/src/endpoints.rs
@@ -665,6 +665,8 @@ impl Api for Server {
pmid: Option<String>,
pmcid: Option<String>,
core_id: Option<String>,
+ arxiv_id: Option<String>,
+ jstor_id: Option<String>,
expand: Option<String>,
hide: Option<String>,
_context: &Context,
@@ -688,6 +690,8 @@ impl Api for Server {
&pmid,
&pmcid,
&core_id,
+ &arxiv_id,
+ &jstor_id,
expand_flags,
hide_flags,
)