From 52f6eaae64013ac4b07477c7cd80391bbc059507 Mon Sep 17 00:00:00 2001 From: abrahamq Date: Fri, 20 Jul 2018 14:04:25 -0400 Subject: [PATCH 1/9] remove indexes, rename outreach tables --- .gitignore | 3 +++ build/run.sh | 6 ++++- schema/outreach/outreach.schema.sql | 34 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 schema/outreach/outreach.schema.sql diff --git a/.gitignore b/.gitignore index eea70eb..1a0b5b3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ backups/ node_modules/ .DS_Store test/node_modules/ + +*.swp +*.swo diff --git a/build/run.sh b/build/run.sh index 58ee75a..3a74da0 100755 --- a/build/run.sh +++ b/build/run.sh @@ -77,9 +77,13 @@ if [ $SCHEMA == true ]; then # Load sensor schema psql -h $PGHOST -p $PGPORT -U $PGUSER -d $PGDATABASE -f $(pwd)/schema/sensors/watersensor.schema.sql - echo "Load new sensors schema" + echo "Load sensors schema" # Load sensors schema psql -h $PGHOST -p $PGPORT -U $PGUSER -d $PGDATABASE -f $(pwd)/schema/sensors/sensors.schema.sql + + echo "Load outreach schema" + # Load outreach schema + psql -h $PGHOST -p $PGPORT -U $PGUSER -d $PGDATABASE -f $(pwd)/schema/outreach/outreach.schema.sql fi # Functions loading diff --git a/schema/outreach/outreach.schema.sql b/schema/outreach/outreach.schema.sql new file mode 100644 index 0000000..df6047d --- /dev/null +++ b/schema/outreach/outreach.schema.sql @@ -0,0 +1,34 @@ +CREATE SCHEMA outreach; + +-- Outreach content table +-- Holds the adCreative +CREATE TABLE outreach.fb_metadata +( + id bigserial NOT NULL, + fb_id bigint NOT NULL, + created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + properties JSONB NOT NULL, + CONSTRAINT outreach_fb_metadata_pkey PRIMARY KEY (id) +); + +-- Outreach data table +-- Has facebook insight information +CREATE TABLE outreach.fb_data +( + id bigserial NOT NULL, + f_key bigint NOT NULL, + fb_id bigint NOT NULL, + created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + properties JSONB NOT NULL, + CONSTRAINT outreach_fb_data_pkey PRIMARY KEY (id), + CONSTRAINT outreach_fb_data_fkey FOREIGN KEY (f_key) + REFERENCES outreach.fb_metadata (id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +); + +-- Add a geometry column +SELECT AddGeometryColumn('outreach', 'fb_data', 'the_geom', 4326, 'POINT', 2); +ALTER TABLE outreach.data ALTER COLUMN the_geom SET NOT NULL; + +-- Add a GIST spatial index +CREATE INDEX gix_outreach_fb_data ON outreach.fb_data USING gist(the_geom); From a0b63e511a25273ca556644acbc561a58e27cb3d Mon Sep 17 00:00:00 2001 From: abrahamq Date: Mon, 20 Aug 2018 09:02:55 -0400 Subject: [PATCH 2/9] move from point to polygon --- schema/outreach/outreach.schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/outreach/outreach.schema.sql b/schema/outreach/outreach.schema.sql index df6047d..91919f9 100644 --- a/schema/outreach/outreach.schema.sql +++ b/schema/outreach/outreach.schema.sql @@ -27,7 +27,7 @@ CREATE TABLE outreach.fb_data ); -- Add a geometry column -SELECT AddGeometryColumn('outreach', 'fb_data', 'the_geom', 4326, 'POINT', 2); +SELECT AddGeometryColumn('outreach', 'fb_data', 'the_geom', 4326, 'POLYGON', 2); ALTER TABLE outreach.data ALTER COLUMN the_geom SET NOT NULL; -- Add a GIST spatial index From 5c5457c964122c6dce26bb97119fbd3e60d3e9c3 Mon Sep 17 00:00:00 2001 From: abrahamq Date: Wed, 29 Aug 2018 11:10:04 -0400 Subject: [PATCH 3/9] add unique fb id --- schema/outreach/outreach.schema.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema/outreach/outreach.schema.sql b/schema/outreach/outreach.schema.sql index 91919f9..c3b33ae 100644 --- a/schema/outreach/outreach.schema.sql +++ b/schema/outreach/outreach.schema.sql @@ -5,7 +5,7 @@ CREATE SCHEMA outreach; CREATE TABLE outreach.fb_metadata ( id bigserial NOT NULL, - fb_id bigint NOT NULL, + fb_id bigint NOT NULL UNIQUE, created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), properties JSONB NOT NULL, CONSTRAINT outreach_fb_metadata_pkey PRIMARY KEY (id) @@ -17,7 +17,7 @@ CREATE TABLE outreach.fb_data ( id bigserial NOT NULL, f_key bigint NOT NULL, - fb_id bigint NOT NULL, + fb_id bigint NOT NULL UNIQUE, created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), properties JSONB NOT NULL, CONSTRAINT outreach_fb_data_pkey PRIMARY KEY (id), From 3529f1ca8835933ce854bc22f00ab6d866a6dca5 Mon Sep 17 00:00:00 2001 From: abrahamq Date: Wed, 5 Sep 2018 13:26:19 -0400 Subject: [PATCH 4/9] new release candidate for outreach --- CHANGELOG.md | 3 +++ build/run.sh | 4 ---- package-lock.json | 2 +- package.json | 2 +- schema/cognicity/cognicity.functions.sql | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4df6bb0..2ad2b15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,3 +37,6 @@ CHANGE LOG - added waterways and basins data for Broward County, FL - deleted old Jakarta infrastructure folder - added instance regions and local areas for Madhubani, Kerala + +### v3.2.0 +- added outreach schema for fb ads. diff --git a/build/run.sh b/build/run.sh index 4c689c1..bfebbe4 100755 --- a/build/run.sh +++ b/build/run.sh @@ -69,10 +69,6 @@ if [ $SCHEMA == true ]; then # Load the pumps, floodgates and waterways infrastructure schema data psql -h $PGHOST -p $PGPORT -U $PGUSER -d $PGDATABASE -f $(pwd)/schema/infrastructure/infrastructure.schema.sql - echo "Load water sensor schema" - # Load water sensor schema - psql -h $PGHOST -p $PGPORT -U $PGUSER -d $PGDATABASE -f $(pwd)/schema/sensors/watersensor.schema.sql - echo "Load sensors schema" # Load sensors schema psql -h $PGHOST -p $PGPORT -U $PGUSER -d $PGDATABASE -f $(pwd)/schema/sensors/sensors.schema.sql diff --git a/package-lock.json b/package-lock.json index 15d8e62..b11b5c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cognicity-schema", - "version": "3.1.0", + "version": "3.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index dd2d076..001f3b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cognicity-schema", - "version": "3.1.1", + "version": "3.2.0", "description": "Cognicity Database Schema", "engines": { "node": ">=8.1.4" diff --git a/schema/cognicity/cognicity.functions.sql b/schema/cognicity/cognicity.functions.sql index 3020b96..373050a 100644 --- a/schema/cognicity/cognicity.functions.sql +++ b/schema/cognicity/cognicity.functions.sql @@ -113,7 +113,7 @@ CREATE FUNCTION cognicity.version() RETURNS varchar AS $BODY$ BEGIN - RETURN '3.1.0'; + RETURN '3.2.0'; END $BODY$ LANGUAGE plpgsql VOLATILE From 3259bf93ca57937512b258c0337e47037b3c3412 Mon Sep 17 00:00:00 2001 From: ojha-url Date: Mon, 1 Oct 2018 17:38:31 -0400 Subject: [PATCH 5/9] Added SFWMD site in Broward deployment --- data/us/infrastructure/sites.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/us/infrastructure/sites.sql b/data/us/infrastructure/sites.sql index 4c42179..d2761bf 100644 --- a/data/us/infrastructure/sites.sql +++ b/data/us/infrastructure/sites.sql @@ -17,4 +17,5 @@ INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('S-37B SPILLWAY INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('S-38 CULVERT ON CANAL C-14 AT CONSERVATION AREA 2A', '{"instance_region_code":"brw", "site": "S38", "basin": "C14"}', '01010000A0E6100000D46A406B1B1354C05D182B62BF3A3A400000000000000000'); INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('WATER CONTROL STRUCTURE S-381', '{"instance_region_code":"brw", "site": "S381", "basin": "C11"}', '01010000A0E6100000F98D65B0D81A54C03C27C5E0C40F3A400000000000000000'); INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('S-39 ON HILLSBORO CANAL AT CONSERVATION AREA 1', '{"instance_region_code":"brw", "site": "S39", "basin": "HILLS"}', '01010000A0E6100000555D9A350B1354C0BC77C93E185B3A400000000000000000'); -INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('S-9 PUMP FROM SOUTH NEW RIVER CANAL TO C.A. 3A', '{"instance_region_code":"brw", "site": "S9", "basin": "C11"}', '01010000A0E61000001BD82AC1621C54C018E4123CC40F3A400000000000000000'); \ No newline at end of file +INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('S-9 PUMP FROM SOUTH NEW RIVER CANAL TO C.A. 3A', '{"instance_region_code":"brw", "site": "S9", "basin": "C11"}', '01010000A0E61000001BD82AC1621C54C018E4123CC40F3A400000000000000000'); +INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('C11 CANAL WEST OF WESTON RD (WEST OF I75)', '{"instance_region_code":"brw", "site": "C11U75", "basin": "C11"}', '01010000A0E610000031D84786600D54C0B8CA7632F6103A400000000000000000'); From 3e7a32166ba775ed1e25162f5225a8c61b585cb1 Mon Sep 17 00:00:00 2001 From: ojha-url Date: Mon, 1 Oct 2018 18:32:37 -0400 Subject: [PATCH 6/9] Updated sfwmd site coordinates --- data/us/infrastructure/sites.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/us/infrastructure/sites.sql b/data/us/infrastructure/sites.sql index d2761bf..22b39b6 100644 --- a/data/us/infrastructure/sites.sql +++ b/data/us/infrastructure/sites.sql @@ -18,4 +18,4 @@ INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('S-38 CULVERT ON INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('WATER CONTROL STRUCTURE S-381', '{"instance_region_code":"brw", "site": "S381", "basin": "C11"}', '01010000A0E6100000F98D65B0D81A54C03C27C5E0C40F3A400000000000000000'); INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('S-39 ON HILLSBORO CANAL AT CONSERVATION AREA 1', '{"instance_region_code":"brw", "site": "S39", "basin": "HILLS"}', '01010000A0E6100000555D9A350B1354C0BC77C93E185B3A400000000000000000'); INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('S-9 PUMP FROM SOUTH NEW RIVER CANAL TO C.A. 3A', '{"instance_region_code":"brw", "site": "S9", "basin": "C11"}', '01010000A0E61000001BD82AC1621C54C018E4123CC40F3A400000000000000000'); -INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('C11 CANAL WEST OF WESTON RD (WEST OF I75)', '{"instance_region_code":"brw", "site": "C11U75", "basin": "C11"}', '01010000A0E610000031D84786600D54C0B8CA7632F6103A400000000000000000'); +INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('C11 CANAL WEST OF WESTON RD (WEST OF I75)', '{"instance_region_code":"brw", "site": "C11U75", "basin": "C11"}', '01010000A0E61000001FA2D11D441754C04F292B5D2C103A400000000000000000'); From b91fa3bf909f54cf5d66ecb5e19326fc84bd2a46 Mon Sep 17 00:00:00 2001 From: abrahamq Date: Tue, 2 Oct 2018 16:20:17 -0400 Subject: [PATCH 7/9] typo --- schema/outreach/outreach.schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/outreach/outreach.schema.sql b/schema/outreach/outreach.schema.sql index c3b33ae..62858d8 100644 --- a/schema/outreach/outreach.schema.sql +++ b/schema/outreach/outreach.schema.sql @@ -28,7 +28,7 @@ CREATE TABLE outreach.fb_data -- Add a geometry column SELECT AddGeometryColumn('outreach', 'fb_data', 'the_geom', 4326, 'POLYGON', 2); -ALTER TABLE outreach.data ALTER COLUMN the_geom SET NOT NULL; +ALTER TABLE outreach.fb_data ALTER COLUMN the_geom SET NOT NULL; -- Add a GIST spatial index CREATE INDEX gix_outreach_fb_data ON outreach.fb_data USING gist(the_geom); From ee082aa3deaafb46a5b6367174535ef7d5e44c32 Mon Sep 17 00:00:00 2001 From: ojha-url Date: Tue, 2 Oct 2018 16:44:03 -0400 Subject: [PATCH 8/9] Added new SFWMD site for broward dep --- data/us/infrastructure/add_new_site_C11W.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 data/us/infrastructure/add_new_site_C11W.sql diff --git a/data/us/infrastructure/add_new_site_C11W.sql b/data/us/infrastructure/add_new_site_C11W.sql new file mode 100644 index 0000000..c23d8a7 --- /dev/null +++ b/data/us/infrastructure/add_new_site_C11W.sql @@ -0,0 +1 @@ +INSERT INTO infrastructure.sites (name, tags, the_geom) VALUES ('C11 CANAL WEST OF WESTON RD (WEST OF I75)', '{"instance_region_code":"brw", "site": "C11U75", "basin": "C11"}', '01010000A0E61000001FA2D11D441754C04F292B5D2C103A400000000000000000'); From a4de46ee4f7688ae422c16f67ff01659fb71cbb1 Mon Sep 17 00:00:00 2001 From: ojha-url Date: Tue, 2 Oct 2018 16:48:17 -0400 Subject: [PATCH 9/9] Updated changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ad2b15..69fae3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,4 +39,5 @@ CHANGE LOG - added instance regions and local areas for Madhubani, Kerala ### v3.2.0 -- added outreach schema for fb ads. +- added outreach schema for fb ads. +- added C11 West SFWMD site for Broward.