Skip to content

Commit

Permalink
Added publisher website to locationPlatform
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-oconnell committed Feb 15, 2024
1 parent cf654bf commit 3b497d0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Changed
- [561](https://github.com/thoth-pub/thoth/issues/561) - Add PUBLISHER_WEBSITE as a location platform
- [553](https://github.com/thoth-pub/thoth/pull/553) - Upgrade rust to `1.76.0` in production and development `Dockerfile`
- [305](https://github.com/thoth-pub/thoth/issues/305) - Update rust edition to 2021
- [555](https://github.com/thoth-pub/thoth/pull/555) - Remove thoth-client's schema.json with auto-generated GraphQL schema language file on compilation
Expand Down
34 changes: 34 additions & 0 deletions thoth-api/migrations/v0.11.16/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
UPDATE location SET location_platform = 'Other' WHERE location_platform IN (
'Publisher Website',
);

-- Drop the default and unique constraint, otherwise it won't be able to cast to text
ALTER TABLE location ALTER COLUMN location_platform DROP DEFAULT;
DROP INDEX location_uniq_platform_idx;

ALTER TABLE location ALTER COLUMN location_platform TYPE text;
DROP TYPE location_platform;
CREATE TYPE location_platform AS ENUM (
'Project MUSE',
'OAPEN',
'DOAB',
'JSTOR',
'EBSCO Host',
'OCLC KB',
'ProQuest KB',
'ProQuest ExLibris',
'EBSCO KB',
'JISC KB',
'Google Books',
'Internet Archive',
'ScienceOpen',
'SciELO Books'
'Other'
);
ALTER TABLE location ALTER location_platform TYPE location_platform USING location_platform::location_platform;
ALTER TABLE location
ALTER COLUMN location_platform SET DEFAULT 'Other'::location_platform;

CREATE UNIQUE INDEX location_uniq_platform_idx
ON location (publication_id, location_platform)
WHERE NOT location_platform = 'Other'::location_platform;
1 change: 1 addition & 0 deletions thoth-api/migrations/v0.11.16/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TYPE location_platform ADD VALUE 'Publisher Website';
8 changes: 8 additions & 0 deletions thoth-api/src/model/location/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ pub enum LocationPlatform {
#[cfg_attr(feature = "backend", db_rename = "SciELO Books")]
#[strum(serialize = "SciELO Books")]
ScieloBooks,
#[cfg_attr(feature = "backend", db_rename = "Publisher Website")]
#[strum(serialize = "Publisher Website")]
PublisherWebsite,
#[cfg_attr(feature = "backend", db_rename = "Other")]
#[default]
Other,
Expand Down Expand Up @@ -180,6 +183,7 @@ fn test_locationplatform_display() {
);
assert_eq!(format!("{}", LocationPlatform::ScienceOpen), "ScienceOpen");
assert_eq!(format!("{}", LocationPlatform::ScieloBooks), "SciELO Books");
assert_eq!(format!("{}", LocationPlatform::PublisherWebsite), "Publisher Website");
assert_eq!(format!("{}", LocationPlatform::Other), "Other");
}

Expand Down Expand Up @@ -242,6 +246,10 @@ fn test_locationplatform_fromstr() {
LocationPlatform::from_str("SciELO Books").unwrap(),
LocationPlatform::ScieloBooks
);
assert_eq!(
LocationPlatform::from_str("Publisher Website").unwrap(),
LocationPlatform::PublisherWebsite
);
assert_eq!(
LocationPlatform::from_str("Other").unwrap(),
LocationPlatform::Other
Expand Down

0 comments on commit 3b497d0

Please sign in to comment.