Skip to content

Commit

Permalink
Fixed migration, added crossmark_doi to files
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-oconnell committed Mar 14, 2024
1 parent fcafbb8 commit b700f10
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion thoth-api/migrations/v0.11.19/up.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE imprint
ADD crossmark_doi TEXT CHECK (doi ~* 'https:\/\/doi.org\/10.\d{4,9}\/[-._\;\(\)\/:a-zA-Z0-9]+$');
ADD COLUMN crossmark_doi TEXT CHECK (crossmark_doi ~* 'https:\/\/doi.org\/10.\d{4,9}\/[-._\;\(\)\/:a-zA-Z0-9]+$');
6 changes: 6 additions & 0 deletions thoth-api/src/graphql/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3035,10 +3035,16 @@ impl Imprint {
&self.imprint_name
}

#[graphql(description = "URL of the imprint's landing page")]
pub fn imprint_url(&self) -> Option<&String> {
self.imprint_url.as_ref()
}

#[graphql(description = "DOI of the imprint's Crossmark policy page, if publisher participates. Crossmark, a service from Crossref, 'gives readers quick and easy access to the current status of an item of content, including any corrections, retractions, or updates to that record'. Learn more: https://www.crossref.org/services/crossmark/")]
pub fn crossmark_doi(&self) -> Option<&String> {
self.crossmark_doi.as_ref()
}

pub fn created_at(&self) -> Timestamp {
self.created_at.clone()
}
Expand Down
11 changes: 11 additions & 0 deletions thoth-api/src/model/imprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub enum ImprintField {
ImprintName,
#[strum(serialize = "ImprintURL")]
ImprintUrl,
#[strum(serialize = "CrossmarkDOI")]
CrossmarkDOI,
CreatedAt,
UpdatedAt,
}
Expand All @@ -39,6 +41,7 @@ pub struct Imprint {
pub publisher_id: Uuid,
pub imprint_name: String,
pub imprint_url: Option<String>,
pub crossref_doi: Option<String>,
pub created_at: Timestamp,
pub updated_at: Timestamp,
}
Expand All @@ -49,6 +52,7 @@ pub struct ImprintWithPublisher {
pub imprint_id: Uuid,
pub imprint_name: String,
pub imprint_url: Option<String>,
pub crossref_doi: Option<String>,
pub updated_at: Timestamp,
pub publisher: Publisher,
}
Expand All @@ -62,6 +66,7 @@ pub struct NewImprint {
pub publisher_id: Uuid,
pub imprint_name: String,
pub imprint_url: Option<String>,
pub crossref_doi: Option<String>,
}

#[cfg_attr(
Expand All @@ -74,6 +79,7 @@ pub struct PatchImprint {
pub publisher_id: Uuid,
pub imprint_name: String,
pub imprint_url: Option<String>,
pub crossref_doi: Option<String>,
}

#[cfg_attr(feature = "backend", derive(Queryable))]
Expand Down Expand Up @@ -118,6 +124,7 @@ fn test_imprintfield_display() {
assert_eq!(format!("{}", ImprintField::ImprintId), "ID");
assert_eq!(format!("{}", ImprintField::ImprintName), "Imprint");
assert_eq!(format!("{}", ImprintField::ImprintUrl), "ImprintURL");
assert_eq!(format!("{}", ImprintField::CrossmarkDOI), "CrossmarkDOI");
assert_eq!(format!("{}", ImprintField::CreatedAt), "CreatedAt");
assert_eq!(format!("{}", ImprintField::UpdatedAt), "UpdatedAt");
}
Expand All @@ -137,6 +144,10 @@ fn test_imprintfield_fromstr() {
ImprintField::from_str("ImprintURL").unwrap(),
ImprintField::ImprintUrl
);
assert_eq!(
ImprintField::from_str("CrossmarkDOI").unwrap(),
ImprintField::CrossmarkDOI
);
assert_eq!(
ImprintField::from_str("CreatedAt").unwrap(),
ImprintField::CreatedAt
Expand Down
1 change: 1 addition & 0 deletions thoth-api/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ table! {
publisher_id -> Uuid,
imprint_name -> Text,
imprint_url -> Nullable<Text>,
crossmark_doi -> Nullable<Text>,
created_at -> Timestamptz,
updated_at -> Timestamptz,
}
Expand Down

0 comments on commit b700f10

Please sign in to comment.