Skip to content

Commit

Permalink
Merge pull request #599 from thoth-pub/feature/545_zenodo_location
Browse files Browse the repository at this point in the history
Add Zenodo as a location platform (#545, #542)
  • Loading branch information
rhigman authored Apr 29, 2024
2 parents b018c59 + cf858c0 commit 02e7ab6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- [545](https://github.com/thoth-pub/thoth/issues/545) - Add Zenodo as a location platform

## [[0.12.3]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.3) - 2024-04-26
### Added
Expand Down
33 changes: 33 additions & 0 deletions thoth-api/migrations/v0.12.4/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
UPDATE location SET location_platform = 'Other' WHERE location_platform = 'Zenodo';

-- 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',
'Publisher Website',
'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.12.4/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TYPE location_platform ADD VALUE IF NOT EXISTS 'Zenodo';
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 = "Zenodo")]
#[strum(serialize = "Zenodo")]
Zenodo,
#[cfg_attr(feature = "backend", db_rename = "Publisher Website")]
#[strum(serialize = "Publisher Website")]
PublisherWebsite,
Expand Down Expand Up @@ -183,6 +186,7 @@ fn test_locationplatform_display() {
);
assert_eq!(format!("{}", LocationPlatform::ScienceOpen), "ScienceOpen");
assert_eq!(format!("{}", LocationPlatform::ScieloBooks), "SciELO Books");
assert_eq!(format!("{}", LocationPlatform::Zenodo), "Zenodo");
assert_eq!(
format!("{}", LocationPlatform::PublisherWebsite),
"Publisher Website"
Expand Down Expand Up @@ -249,6 +253,10 @@ fn test_locationplatform_fromstr() {
LocationPlatform::from_str("SciELO Books").unwrap(),
LocationPlatform::ScieloBooks
);
assert_eq!(
LocationPlatform::from_str("Zenodo").unwrap(),
LocationPlatform::Zenodo
);
assert_eq!(
LocationPlatform::from_str("Publisher Website").unwrap(),
LocationPlatform::PublisherWebsite
Expand Down

0 comments on commit 02e7ab6

Please sign in to comment.