Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Zenodo as a location platform (#545, #542) #599

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading