-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
2,173 additions
and
774 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
@@ -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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
@@ -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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
@@ -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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.