Skip to content

Commit

Permalink
Merge pull request #56 from Gustry/label_en
Browse files Browse the repository at this point in the history
SQL - Switch from label to label_en in the glossary
  • Loading branch information
Gustry authored Jan 21, 2021
2 parents e9ec233 + 4ca7420 commit 6e96201
Show file tree
Hide file tree
Showing 8 changed files with 785 additions and 1,437 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ If you don't want to setup a custom repository, you can download the ZIP file fr

## Running migrations

Environment variable `TEST_DATABASE_INSTALL_PGMETADATA = 0.0.1`
Environment variable

```python
import os
os.environ['TEST_DATABASE_INSTALL_PGMETADATA'] = '0.0.1'
```
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ CREATE TABLE pgmetadata.glossary (
id integer NOT NULL,
field text NOT NULL,
code text NOT NULL,
label text NOT NULL,
description text,
label_en text NOT NULL,
description_en text,
item_order smallint,
label_fr text,
description_fr text,
Expand Down
2 changes: 1 addition & 1 deletion pg_metadata/install/sql/pgmetadata/30_VIEW.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CREATE VIEW pgmetadata.v_glossary AS
WITH one AS (
SELECT glossary.field,
glossary.code,
json_build_object('label', json_build_object('en', glossary.label, 'fr', COALESCE(NULLIF(glossary.label_fr, ''::text), glossary.label, ''::text), 'it', COALESCE(NULLIF(glossary.label_it, ''::text), glossary.label, ''::text), 'es', COALESCE(NULLIF(glossary.label_es, ''::text), glossary.label, ''::text), 'de', COALESCE(NULLIF(glossary.label_de, ''::text), glossary.label, ''::text)), 'description', json_build_object('en', glossary.description, 'fr', COALESCE(NULLIF(glossary.description_fr, ''::text), glossary.description, ''::text), 'it', COALESCE(NULLIF(glossary.description_it, ''::text), glossary.description, ''::text), 'es', COALESCE(NULLIF(glossary.description_es, ''::text), glossary.description, ''::text), 'de', COALESCE(NULLIF(glossary.description_de, ''::text), glossary.description, ''::text))) AS dict
json_build_object('label', json_build_object('en', glossary.label_en, 'fr', COALESCE(NULLIF(glossary.label_fr, ''::text), glossary.label_en, ''::text), 'it', COALESCE(NULLIF(glossary.label_it, ''::text), glossary.label_en, ''::text), 'es', COALESCE(NULLIF(glossary.label_es, ''::text), glossary.label_en, ''::text), 'de', COALESCE(NULLIF(glossary.label_de, ''::text), glossary.label_en, ''::text)), 'description', json_build_object('en', glossary.description_en, 'fr', COALESCE(NULLIF(glossary.description_fr, ''::text), glossary.description_en, ''::text), 'it', COALESCE(NULLIF(glossary.description_it, ''::text), glossary.description_en, ''::text), 'es', COALESCE(NULLIF(glossary.description_es, ''::text), glossary.description_en, ''::text), 'de', COALESCE(NULLIF(glossary.description_de, ''::text), glossary.description_en, ''::text))) AS dict
FROM pgmetadata.glossary
), two AS (
SELECT one.field,
Expand Down
8 changes: 4 additions & 4 deletions pg_metadata/install/sql/pgmetadata/70_COMMENT.sql
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ COMMENT ON COLUMN pgmetadata.glossary.field IS 'Field name';
COMMENT ON COLUMN pgmetadata.glossary.code IS 'Item code';


-- glossary.label
COMMENT ON COLUMN pgmetadata.glossary.label IS 'Item label';
-- glossary.label_en
COMMENT ON COLUMN pgmetadata.glossary.label_en IS 'Item label';


-- glossary.description
COMMENT ON COLUMN pgmetadata.glossary.description IS 'Description';
-- glossary.description_en
COMMENT ON COLUMN pgmetadata.glossary.description_en IS 'Description';


-- glossary.item_order
Expand Down
258 changes: 129 additions & 129 deletions pg_metadata/install/sql/pgmetadata/90_GLOSSARY.sql

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions pg_metadata/install/sql/upgrade/upgrade_to_0.4.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -710,4 +710,11 @@ COMMENT ON VIEW pgmetadata.v_contact IS

-- End contact role

-- Start glossary EN

ALTER TABLE pgmetadata.glossary RENAME COLUMN label TO label_en;
ALTER TABLE pgmetadata.glossary RENAME COLUMN description TO description_en;

-- End glossary EN

COMMIT;
1,934 changes: 634 additions & 1,300 deletions pg_metadata/resources/projects/pg_metadata_administration.qgs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pg_metadata/test/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def test_generating_admin_project(self):
with open(template_file, 'r') as fin:
file_data = fin.read()

self.assertGreater(file_data.count("estimatedmetadata=true"), 20)

self.assertIn("service='pgmetadata'", file_data)
self.assertNotIn("host=db", file_data)

Expand Down

0 comments on commit 6e96201

Please sign in to comment.