Skip to content

Commit

Permalink
Merge branch 'release/v0.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 committed Mar 1, 2022
2 parents 06c1bad + 795eb91 commit 8c5c578
Show file tree
Hide file tree
Showing 44 changed files with 2,173 additions and 774 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[0.8.0]](https://github.com/thoth-pub/thoth/releases/tag/v0.8.0) - 2022-03-01
### Added
- [#341](https://github.com/thoth-pub/thoth/issues/341) - Add weight to publication

### Changed
- Tidied verbose bools and single-character strings to comply with [`rustc 1.59.0`](https://github.com/rust-lang/rust/releases/tag/1.59.0)
- [#300](https://github.com/thoth-pub/thoth/issues/300) - Moved width/height to Publication, added depth, improved metric/imperial display
- Upgrade docker's base images to latest available releases

## [[0.7.2]](https://github.com/thoth-pub/thoth/releases/tag/v0.7.2) - 2022-02-08
### Changed
- [#339](https://github.com/thoth-pub/thoth/pull/339) - Update publication types to include AZW3, DOCX and FictionBook
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thoth"
version = "0.7.2"
version = "0.8.0"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -16,11 +16,11 @@ maintenance = { status = "actively-developed" }
members = ["thoth-api", "thoth-api-server", "thoth-app", "thoth-app-server", "thoth-client", "thoth-errors", "thoth-export-server"]

[dependencies]
thoth-api = { version = "0.7.2", path = "thoth-api", features = ["backend"] }
thoth-api-server = { version = "0.7.2", path = "thoth-api-server" }
thoth-app-server = { version = "0.7.2", path = "thoth-app-server" }
thoth-errors = { version = "0.7.2", path = "thoth-errors" }
thoth-export-server = { version = "0.7.2", path = "thoth-export-server" }
thoth-api = { version = "0.8.0", path = "thoth-api", features = ["backend"] }
thoth-api-server = { version = "0.8.0", path = "thoth-api-server" }
thoth-app-server = { version = "0.8.0", path = "thoth-app-server" }
thoth-errors = { version = "0.8.0", path = "thoth-errors" }
thoth-export-server = { version = "0.8.0", path = "thoth-export-server" }
clap = "2.33.3"
dialoguer = "0.7.1"
dotenv = "0.9.0"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG RUST_IMAGE=rust:1.56.0
ARG MUSL_IMAGE=ekidd/rust-musl-builder:1.51.0
ARG RUST_IMAGE=rust:1.59.0
ARG MUSL_IMAGE=ekidd/rust-musl-builder:1.57.0

FROM ${RUST_IMAGE} as wasm

Expand Down
6 changes: 3 additions & 3 deletions thoth-api-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thoth-api-server"
version = "0.7.2"
version = "0.8.0"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -9,8 +9,8 @@ repository = "https://github.com/thoth-pub/thoth"
readme = "README.md"

[dependencies]
thoth-api = { version = "0.7.2", path = "../thoth-api", features = ["backend"] }
thoth-errors = { version = "0.7.2", path = "../thoth-errors" }
thoth-api = { version = "0.8.0", path = "../thoth-api", features = ["backend"] }
thoth-errors = { version = "0.8.0", path = "../thoth-errors" }
actix-web = "3.3.2"
actix-cors = "0.5.4"
actix-identity = "0.3.1"
Expand Down
4 changes: 2 additions & 2 deletions thoth-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thoth-api"
version = "0.7.2"
version = "0.8.0"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -16,7 +16,7 @@ maintenance = { status = "actively-developed" }
backend = ["diesel", "diesel-derive-enum", "diesel_migrations", "futures", "actix-web"]

[dependencies]
thoth-errors = { version = "0.7.2", path = "../thoth-errors" }
thoth-errors = { version = "0.8.0", path = "../thoth-errors" }
actix-web = { version = "3.3.2", optional = true }
argon2rs = "0.2.5"
isbn2 = "0.4.0"
Expand Down
63 changes: 63 additions & 0 deletions thoth-api/migrations/0.8.0/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
ALTER TABLE work
ADD COLUMN width double precision CHECK (width > 0.0),
ADD COLUMN height double precision CHECK (height > 0.0),
ADD CONSTRAINT work_chapter_no_width CHECK
(width IS NULL OR work_type <> 'book-chapter'),
ADD CONSTRAINT work_chapter_no_height CHECK
(height IS NULL OR work_type <> 'book-chapter');

-- Migrate publication dimension information back into work table as far as possible
-- (width/height in mm only) before dropping publication dimension columns. Where
-- dimensions for both paperback and hardback are given, assume the paperback is canonical.
UPDATE work
SET width = publication.width_mm
FROM publication
WHERE work.work_type <> 'book-chapter'
AND work.work_id = publication.work_id
AND publication.width_mm IS NOT NULL
AND publication.publication_type = 'Paperback';
UPDATE work
SET width = publication.width_mm
FROM publication
WHERE work.work_type <> 'book-chapter'
AND work.work_id = publication.work_id
AND work.width IS NULL
AND publication.width_mm IS NOT NULL
AND publication.publication_type = 'Hardback';

UPDATE work
SET height = publication.height_mm
FROM publication
WHERE work.work_type <> 'book-chapter'
AND work.work_id = publication.work_id
AND publication.height_mm IS NOT NULL
AND publication.publication_type = 'Paperback';
UPDATE work
SET height = publication.height_mm
FROM publication
WHERE work.work_type <> 'book-chapter'
AND work.work_id = publication.work_id
AND work.height IS NULL
AND publication.height_mm IS NOT NULL
AND publication.publication_type = 'Hardback';

DROP TRIGGER publication_chapter_no_dimensions_check ON publication;

ALTER TABLE publication
DROP CONSTRAINT publication_non_physical_no_dimensions,
DROP CONSTRAINT publication_weight_g_not_missing,
DROP CONSTRAINT publication_weight_oz_not_missing,
DROP CONSTRAINT publication_width_mm_not_missing,
DROP CONSTRAINT publication_width_in_not_missing,
DROP CONSTRAINT publication_height_mm_not_missing,
DROP CONSTRAINT publication_height_in_not_missing,
DROP CONSTRAINT publication_depth_mm_not_missing,
DROP CONSTRAINT publication_depth_in_not_missing,
DROP COLUMN weight_g,
DROP COLUMN weight_oz,
DROP COLUMN width_mm,
DROP COLUMN width_in,
DROP COLUMN height_mm,
DROP COLUMN height_in,
DROP COLUMN depth_mm,
DROP COLUMN depth_in;
88 changes: 88 additions & 0 deletions thoth-api/migrations/0.8.0/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
ALTER TABLE publication
ADD COLUMN width_mm double precision CHECK (width_mm > 0.0),
ADD COLUMN width_in double precision CHECK (width_in > 0.0),
ADD COLUMN height_mm double precision CHECK (height_mm > 0.0),
ADD COLUMN height_in double precision CHECK (height_in > 0.0),
ADD COLUMN depth_mm double precision CHECK (depth_mm > 0.0),
ADD COLUMN depth_in double precision CHECK (depth_in > 0.0),
ADD COLUMN weight_g double precision CHECK (weight_g > 0.0),
ADD COLUMN weight_oz double precision CHECK (weight_oz > 0.0),
ADD CONSTRAINT publication_non_physical_no_dimensions CHECK
((width_mm IS NULL AND width_in IS NULL
AND height_mm IS NULL AND height_in IS NULL
AND depth_mm IS NULL AND depth_in IS NULL
AND weight_g IS NULL AND weight_oz IS NULL)
OR publication_type = 'Paperback' OR publication_type = 'Hardback'),
ADD CONSTRAINT publication_depth_mm_not_missing CHECK
(depth_mm IS NOT NULL OR depth_in IS NULL),
ADD CONSTRAINT publication_depth_in_not_missing CHECK
(depth_in IS NOT NULL OR depth_mm IS NULL),
ADD CONSTRAINT publication_weight_g_not_missing CHECK
(weight_g IS NOT NULL OR weight_oz IS NULL),
ADD CONSTRAINT publication_weight_oz_not_missing CHECK
(weight_oz IS NOT NULL OR weight_g IS NULL);

CREATE OR REPLACE FUNCTION publication_chapter_no_dimensions() RETURNS trigger AS $$
BEGIN
IF (
(SELECT work_type FROM work WHERE work.work_id = NEW.work_id) = 'book-chapter' AND (
NEW.width_mm IS NOT NULL OR
NEW.width_in IS NOT NULL OR
NEW.height_mm IS NOT NULL OR
NEW.height_in IS NOT NULL OR
NEW.depth_mm IS NOT NULL OR
NEW.depth_in IS NOT NULL OR
NEW.weight_g IS NOT NULL OR
NEW.weight_oz IS NOT NULL
)
) THEN
RAISE EXCEPTION 'Chapters cannot have dimensions (Width/Height/Depth/Weight)';
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER publication_chapter_no_dimensions_check BEFORE INSERT OR UPDATE ON publication
FOR EACH ROW EXECUTE PROCEDURE publication_chapter_no_dimensions();

-- Migrate work dimension information into publication table before dropping work
-- width/height columns. Assume dimensions are same for paperback and hardback.
UPDATE publication
SET width_mm = work.width
FROM work
WHERE publication.work_id = work.work_id
AND work.width IS NOT NULL
AND (publication.publication_type = 'Paperback' OR publication.publication_type = 'Hardback');

UPDATE publication
SET height_mm = work.height
FROM work
WHERE publication.work_id = work.work_id
AND work.height IS NOT NULL
AND (publication.publication_type = 'Paperback' OR publication.publication_type = 'Hardback');

-- Add imperial dimension information based on metric. Conversion logic used here
-- replicates convert_length_from_to() function in thoth-api/src/model/mod.rs.
UPDATE publication
SET width_in = round((width_mm / 25.4)::numeric, 2)
WHERE width_mm IS NOT NULL;

UPDATE publication
SET height_in = round((height_mm / 25.4)::numeric, 2)
WHERE height_mm IS NOT NULL;

ALTER TABLE publication
ADD CONSTRAINT publication_width_mm_not_missing CHECK
(width_mm IS NOT NULL OR width_in IS NULL),
ADD CONSTRAINT publication_width_in_not_missing CHECK
(width_in IS NOT NULL OR width_mm IS NULL),
ADD CONSTRAINT publication_height_mm_not_missing CHECK
(height_mm IS NOT NULL OR height_in IS NULL),
ADD CONSTRAINT publication_height_in_not_missing CHECK
(height_in IS NOT NULL OR height_mm IS NULL);

ALTER TABLE work
DROP CONSTRAINT work_chapter_no_width,
DROP CONSTRAINT work_chapter_no_height,
DROP COLUMN width,
DROP COLUMN height;
Loading

0 comments on commit 8c5c578

Please sign in to comment.