diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..a47c819d Binary files /dev/null and b/.DS_Store differ diff --git a/reporting/.env b/reporting/.env index 0b9fed00..f7103e48 100644 --- a/reporting/.env +++ b/reporting/.env @@ -84,3 +84,9 @@ CLIENT_SECRET=changeme DB_PASSWORD=p@ssw0rd FHIR_ID=trusted-client FHIR_PASSWORD=secret +### Database ### +DATABASE_USERNAME=reporting +DATABASE_PASSWORD=0b39aca786e3 +DATABASE_HOST=uat-reporting.cpmydgulhchj.us-east-1.rds.amazonaws.com +DATABASE_PORT=5432 +DATABASE_NAME=openlmis_reporting diff --git a/reporting/config/.DS_Store b/reporting/config/.DS_Store new file mode 100644 index 00000000..982b1e4b Binary files /dev/null and b/reporting/config/.DS_Store differ diff --git a/reporting/config/services/.DS_Store b/reporting/config/services/.DS_Store new file mode 100644 index 00000000..8c8f1c38 Binary files /dev/null and b/reporting/config/services/.DS_Store differ diff --git a/reporting/config/services/nifi/.DS_Store b/reporting/config/services/nifi/.DS_Store new file mode 100644 index 00000000..418eef2c Binary files /dev/null and b/reporting/config/services/nifi/.DS_Store differ diff --git a/reporting/config/services/nifi/scripts/.DS_Store b/reporting/config/services/nifi/scripts/.DS_Store new file mode 100644 index 00000000..4a1ce8a8 Binary files /dev/null and b/reporting/config/services/nifi/scripts/.DS_Store differ diff --git a/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/generate-measure-report.properties b/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/generate-measure-report.properties index a1b91e84..e997d9bd 100644 --- a/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/generate-measure-report.properties +++ b/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/generate-measure-report.properties @@ -1,3 +1,3 @@ bucketIdentifier=9a51b9f4-c902-463c-a440-4bfdac0dea6a flowIdentifier=5aba1b21-32b5-462f-ae50-c49a6f975b57 -flowVersion=5 \ No newline at end of file +flowVersion=5 diff --git a/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/generate-measure.properties b/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/generate-measure.properties index 286c01c7..9f5a400e 100644 --- a/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/generate-measure.properties +++ b/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/generate-measure.properties @@ -1,3 +1,3 @@ bucketIdentifier=9a51b9f4-c902-463c-a440-4bfdac0dea6a flowIdentifier=77a5e697-b3ae-4f91-8c4b-309bd3a5b82b -flowVersion=6 \ No newline at end of file +flowVersion=6 diff --git a/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/get-openlmis-v3-reference-geo-data.properties b/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/get-openlmis-v3-reference-geo-data.properties index 656fc262..8f5c75be 100644 --- a/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/get-openlmis-v3-reference-geo-data.properties +++ b/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/get-openlmis-v3-reference-geo-data.properties @@ -1,7 +1,3 @@ bucketIdentifier=9a51b9f4-c902-463c-a440-4bfdac0dea6a flowIdentifier=0bfb3822-cbfc-4b12-8e04-07ae7cf53676 -<<<<<<< HEAD -flowVersion=7 -======= flowVersion=10 ->>>>>>> Update flow versions diff --git a/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/materialized-views.properties b/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/materialized-views.properties index 15b72887..20b4105b 100644 --- a/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/materialized-views.properties +++ b/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/materialized-views.properties @@ -1,7 +1,3 @@ bucketIdentifier=9a51b9f4-c902-463c-a440-4bfdac0dea6a flowIdentifier=0a58beda-92c0-492e-90bd-14a6447471fd -<<<<<<< HEAD -flowVersion=8 -======= flowVersion=9 ->>>>>>> Update flow versions diff --git a/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/superset-permissions.properties b/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/superset-permissions.properties index aaad8e95..280c3fdf 100644 --- a/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/superset-permissions.properties +++ b/reporting/config/services/nifi/scripts/preload/process-groups/OpenLMIS/superset-permissions.properties @@ -1,3 +1,3 @@ bucketIdentifier=9a51b9f4-c902-463c-a440-4bfdac0dea6a flowIdentifier=ded26cb5-a4a1-46f8-b2c7-c31dfad03a57 -flowVersion=9 \ No newline at end of file +flowVersion=9 diff --git a/reporting/config/services/superset/dashboards/openlmis_uat_dashboards.json b/reporting/config/services/superset/dashboards/openlmis_uat_dashboards.json index 2fbed864..f68be0af 100644 --- a/reporting/config/services/superset/dashboards/openlmis_uat_dashboards.json +++ b/reporting/config/services/superset/dashboards/openlmis_uat_dashboards.json @@ -777,7 +777,7 @@ "database_name": "main", "created_by_fk": null, "allow_ctas": false, - "sqlalchemy_uri": "postgresql+psycopg2://postgres:XXXXXXXXXX@db:5432/open_lmis_reporting", + "sqlalchemy_uri": "postgresql+psycopg2://${DATABASE_USERNAME}:XXXXXXXXXX@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}g", "changed_by_fk": null, "allow_dml": false, "password": "p@ssw0rd", @@ -2359,7 +2359,7 @@ "database_name": "main", "created_by_fk": null, "allow_ctas": false, - "sqlalchemy_uri": "postgresql+psycopg2://postgres:XXXXXXXXXX@db:5432/open_lmis_reporting", + "sqlalchemy_uri": "postgresql+psycopg2://${DATABASE_USERNAME}:XXXXXXXXXX@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}g", "changed_by_fk": null, "allow_dml": false, "password": "p@ssw0rd", @@ -3433,7 +3433,7 @@ "database_name": "main", "created_by_fk": null, "allow_ctas": false, - "sqlalchemy_uri": "postgresql+psycopg2://postgres:XXXXXXXXXX@db:5432/open_lmis_reporting", + "sqlalchemy_uri": "postgresql+psycopg2://${DATABASE_USERNAME}:XXXXXXXXXX@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}g", "changed_by_fk": null, "allow_dml": false, "password": "p@ssw0rd", @@ -6677,7 +6677,7 @@ "database_name": "main", "created_by_fk": null, "allow_ctas": false, - "sqlalchemy_uri": "postgresql+psycopg2://postgres:XXXXXXXXXX@db:5432/open_lmis_reporting", + "sqlalchemy_uri": "postgresql+psycopg2://${DATABASE_USERNAME}:XXXXXXXXXX@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}g", "changed_by_fk": null, "allow_dml": false, "password": "p@ssw0rd", diff --git a/reporting/config/services/superset/datasources/database.yaml b/reporting/config/services/superset/datasources/database.yaml index 88422afe..fb6ea7e7 100644 --- a/reporting/config/services/superset/datasources/database.yaml +++ b/reporting/config/services/superset/datasources/database.yaml @@ -2,7 +2,7 @@ databases: - database_name: main expose_in_sqllab: true extra: "{\r\n \"metadata_params\": {},\r\n \"engine_params\": {}\r\n}\r\n" - sqlalchemy_uri: postgresql+psycopg2://postgres:XXXXXXXXXX@db:5432/open_lmis_reporting + sqlalchemy_uri: postgresql+psycopg2://${DATABASE_USERNAME}:XXXXXXXXXX@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME} tables: - columns: - {avg: true, column_name: adjusted_consumption, sum: true, type: DOUBLE PRECISION} diff --git a/reporting/config/services/superset/substitute_variables.py b/reporting/config/services/superset/substitute_variables.py new file mode 100644 index 00000000..3353d0b8 --- /dev/null +++ b/reporting/config/services/superset/substitute_variables.py @@ -0,0 +1,23 @@ +import os +import sys +import yaml +import json +from functools import reduce + +variables_map = {'${DATABASE_USERNAME}': os.environ.get('DATABASE_USERNAME'), + '${DATABASE_HOST}': os.environ.get('DATABASE_HOST'), + '${DATABASE_PORT}': os.environ.get('DATABASE_PORT'), + '${DATABASE_NAME}': os.environ.get('DATABASE_NAME')} + +def replace_file_variables(file): + file_data = open(file, 'r').read() + + with open(file, 'w') as f: + f.write(reduce(lambda match, kv: match.replace(*kv), variables_map.items(), file_data)) + +def handle_datasources_dashboards(files): + for i in files: + replace_file_variables(i) + +files = sys.argv[1:] +handle_datasources_dashboards(files) \ No newline at end of file diff --git a/reporting/config/services/superset/superset_config.py b/reporting/config/services/superset/superset_config.py index fb746673..a92dab2c 100644 --- a/reporting/config/services/superset/superset_config.py +++ b/reporting/config/services/superset/superset_config.py @@ -1,11 +1,17 @@ """ Superset config """ +import os from flask_appbuilder.security.manager import AUTH_OAUTH - from superset_patchup.oauth import CustomSecurityManager -SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://postgres:p@ssw0rd@db:5432/open_lmis_reporting' +SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://%(username)s:%(password)s@%(host)s:%(port)s/%(database_name)s' %{ + "username": os.environ.get('DATABASE_USERNAME', 'postgres'), + "password": os.environ.get('DATABASE_PASSWORD', 'p@ssw0rd'), + "host": os.environ.get('DATABASE_HOST', 'db'), + "port": os.environ.get('DATABASE_PORT', '5432'), + "database_name": os.environ.get('DATABASE_NAME', 'open_lmis_reporting') +} SQLALCHEMY_TRACK_MODIFICATIONS = True SECRET_KEY = 'thisISaSECRET_1234' diff --git a/reporting/db/docker-entrypoint-initdb.d/templates/OlmisCreateTableStatements.sql b/reporting/db/docker-entrypoint-initdb.d/templates/OlmisCreateTableStatements.sql index 2b4db1f4..e9d17032 100644 --- a/reporting/db/docker-entrypoint-initdb.d/templates/OlmisCreateTableStatements.sql +++ b/reporting/db/docker-entrypoint-initdb.d/templates/OlmisCreateTableStatements.sql @@ -18,7 +18,7 @@ CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public; COMMENT ON EXTENSION postgis IS 'PostGIS geometry, geography, and raster spatial types and functions'; -- --- Name: commodity_types; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: commodity_types; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE commodity_types ( @@ -30,10 +30,10 @@ CREATE TABLE commodity_types ( ); -ALTER TABLE commodity_types OWNER TO postgres; +ALTER TABLE commodity_types OWNER TO reporting; -- --- Name: facilities; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: facilities; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE facilities ( @@ -59,7 +59,7 @@ CREATE TABLE facilities ( ); -ALTER TABLE facilities OWNER TO postgres; +ALTER TABLE facilities OWNER TO reporting; -- -- Name: ideal_stock_amounts; Type: TABLE; Schema: referencedata; Owner: postgres @@ -74,10 +74,10 @@ CREATE TABLE ideal_stock_amounts ( ); -ALTER TABLE ideal_stock_amounts OWNER TO postgres; +ALTER TABLE ideal_stock_amounts OWNER TO reporting; -- --- Name: lots; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: lots; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE lots ( @@ -90,10 +90,10 @@ CREATE TABLE lots ( ); -ALTER TABLE lots OWNER TO postgres; +ALTER TABLE lots OWNER TO reporting; -- --- Name: orderables; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: orderables; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE orderables ( @@ -118,10 +118,10 @@ CREATE TABLE orderables ( ); -ALTER TABLE orderables OWNER TO postgres; +ALTER TABLE orderables OWNER TO reporting; -- --- Name: processing_periods; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: processing_periods; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE processing_periods ( @@ -134,10 +134,10 @@ CREATE TABLE processing_periods ( ); -ALTER TABLE processing_periods OWNER TO postgres; +ALTER TABLE processing_periods OWNER TO reporting; -- --- Name: program_orderables; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: program_orderables; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE program_orderables ( @@ -153,10 +153,10 @@ CREATE TABLE program_orderables ( ); -ALTER TABLE program_orderables OWNER TO postgres; +ALTER TABLE program_orderables OWNER TO reporting; -- --- Name: programs; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: programs; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE programs ( @@ -172,10 +172,10 @@ CREATE TABLE programs ( ); -ALTER TABLE programs OWNER TO postgres; +ALTER TABLE programs OWNER TO reporting; -- --- Name: requisition_group_members; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: requisition_group_members; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE requisition_group_members ( @@ -184,10 +184,10 @@ CREATE TABLE requisition_group_members ( ); -ALTER TABLE requisition_group_members OWNER TO postgres; +ALTER TABLE requisition_group_members OWNER TO reporting; -- --- Name: requisition_group_program_schedules; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: requisition_group_program_schedules; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE requisition_group_program_schedules ( @@ -200,10 +200,10 @@ CREATE TABLE requisition_group_program_schedules ( ); -ALTER TABLE requisition_group_program_schedules OWNER TO postgres; +ALTER TABLE requisition_group_program_schedules OWNER TO reporting; -- --- Name: supported_programs; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: supported_programs; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE supported_programs ( @@ -215,7 +215,7 @@ CREATE TABLE supported_programs ( ); -ALTER TABLE supported_programs OWNER TO postgres; +ALTER TABLE supported_programs OWNER TO reporting; -- -- Name: trade_items; Type: TABLE; Schema: referencedata; Owner: postgres @@ -228,10 +228,10 @@ CREATE TABLE trade_items ( ); -ALTER TABLE trade_items OWNER TO postgres; +ALTER TABLE trade_items OWNER TO reporting; -- --- Name: rights; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: rights; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE rights ( @@ -241,10 +241,10 @@ CREATE TABLE rights ( ); -ALTER TABLE rights OWNER TO postgres; +ALTER TABLE rights OWNER TO reporting; -- --- Name: users; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: users; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE users ( @@ -258,10 +258,10 @@ CREATE TABLE users ( ); -ALTER TABLE users OWNER TO postgres; +ALTER TABLE users OWNER TO reporting; -- --- Name: roles; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: roles; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE roles ( @@ -275,10 +275,10 @@ CREATE TABLE roles ( ); -ALTER TABLE roles OWNER TO postgres; +ALTER TABLE roles OWNER TO reporting; -- --- Name: supervisorynodes; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: supervisorynodes; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE supervisorynodes ( @@ -294,10 +294,10 @@ CREATE TABLE supervisorynodes ( ); -ALTER TABLE supervisorynodes OWNER TO postgres; +ALTER TABLE supervisorynodes OWNER TO reporting; -- --- Name: requisitiongroups; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: requisitiongroups; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE requisitiongroups ( @@ -315,10 +315,10 @@ CREATE TABLE requisitiongroups ( ); -ALTER TABLE requisitiongroups OWNER TO postgres; +ALTER TABLE requisitiongroups OWNER TO reporting; -- --- Name: supplylines; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: supplylines; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE supplylines ( @@ -330,10 +330,10 @@ CREATE TABLE supplylines ( ); -ALTER TABLE supplylines OWNER TO postgres; +ALTER TABLE supplylines OWNER TO reporting; -- --- Name: requisitions; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: requisitions; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE requisitions ( @@ -375,10 +375,10 @@ CREATE TABLE requisitions ( processing_schedule_name varchar ); -ALTER TABLE requisitions OWNER TO postgres; +ALTER TABLE requisitions OWNER TO reporting; -- --- Name: requisition_line_item; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: requisition_line_item; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE requisition_line_item ( @@ -405,10 +405,10 @@ CREATE TABLE requisition_line_item ( total_received_quantity double precision ); -ALTER TABLE requisition_line_item OWNER TO postgres; +ALTER TABLE requisition_line_item OWNER TO reporting; -- --- Name: requisitions_status_history; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: requisitions_status_history; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE requisitions_status_history ( @@ -418,10 +418,10 @@ CREATE TABLE requisitions_status_history ( created_date date ); -ALTER TABLE requisitions_status_history OWNER TO postgres; +ALTER TABLE requisitions_status_history OWNER TO reporting; -- --- Name: requisitions_adjustment_lines; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: requisitions_adjustment_lines; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE requisitions_adjustment_lines ( @@ -432,10 +432,10 @@ CREATE TABLE requisitions_adjustment_lines ( requisition_line_item_id varchar ); -ALTER TABLE requisitions_adjustment_lines OWNER TO postgres; +ALTER TABLE requisitions_adjustment_lines OWNER TO reporting; -- --- Name: sohlineitems; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: sohlineitems; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE sohlineitems ( @@ -466,10 +466,10 @@ CREATE TABLE sohlineitems ( destination varchar ); -ALTER TABLE sohlineitems OWNER TO postgres; +ALTER TABLE sohlineitems OWNER TO reporting; -- --- Name: facility_access; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: facility_access; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE facility_access ( @@ -478,10 +478,10 @@ CREATE TABLE facility_access ( program varchar ); -ALTER TABLE facility_access OWNER TO postgres; +ALTER TABLE facility_access OWNER TO reporting; -- --- Name: stock_adjustment_reasons; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: stock_adjustment_reasons; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE stock_adjustment_reasons ( @@ -494,10 +494,10 @@ CREATE TABLE stock_adjustment_reasons ( programname varchar ); -ALTER TABLE stock_adjustment_reasons OWNER TO postgres; +ALTER TABLE stock_adjustment_reasons OWNER TO reporting; -- --- Name: reporting_dates; Type: TABLE; Schema: referencedata; Owner: postgres +-- Name: reporting_dates; Type: TABLE; Schema: referencedata; Owner: reporting -- CREATE TABLE reporting_dates ( @@ -506,14 +506,14 @@ CREATE TABLE reporting_dates ( country varchar ); -ALTER TABLE reporting_dates OWNER TO postgres; +ALTER TABLE reporting_dates OWNER TO reporting; -- Insert default values for reporting dates -- INSERT INTO reporting_dates(due_days, late_days, country) VALUES(14, 7, 'Malawi'), (14, 7, 'Mozambique'); --- ---- Name: reporting_rate_and_timeliness; Type: TABLE; Schema: referencedata; Owner: postgres +--- Name: reporting_rate_and_timeliness; Type: TABLE; Schema: referencedata; Owner: reporting --- CREATE MATERIALIZED VIEW reporting_rate_and_timeliness AS SELECT f.id, f.name, f.district, f.region, f.country, f.type, f.operator_name, @@ -562,10 +562,10 @@ LEFT JOIN facility_access fa ON fa.facility = authorized_reqs.facility_id::VARCH ORDER BY authorized_reqs.processing_period_enddate DESC WITH DATA; -ALTER MATERIALIZED VIEW reporting_rate_and_timeliness OWNER TO postgres; +ALTER MATERIALIZED VIEW reporting_rate_and_timeliness OWNER TO reporting; --- ---- Name: adjustments; Type: TABLE; Schema: referencedata; Owner: postgres +--- Name: adjustments; Type: TABLE; Schema: referencedata; Owner: reporting --- CREATE MATERIALIZED VIEW adjustments AS SELECT DISTINCT ON (li.requisition_line_item_id) li.requisition_line_item_id, @@ -587,11 +587,11 @@ LEFT JOIN facility_access fa ON fa.facility = r.facility_id AND fa.program = r.p WHERE sh.status NOT IN ('SKIPPED', 'INITIATED', 'SUBMITTED') ORDER BY li.requisition_line_item_id, r.modified_date DESC NULLS LAST WITH DATA; -ALTER MATERIALIZED VIEW adjustments OWNER TO postgres; +ALTER MATERIALIZED VIEW adjustments OWNER TO reporting; --- ---- Name: stock_status_and_consumption; Type: TABLE; Schema: referencedata; Owner: postgres +--- Name: stock_status_and_consumption; Type: TABLE; Schema: referencedata; Owner: reporting --- CREATE MATERIALIZED VIEW stock_status_and_consumption AS SELECT li.requisition_line_item_id, r.id, @@ -644,4 +644,4 @@ total_losses_and_adjustments, stock_on_hand, total_stockout_days, max_periods_of calculated_order_quantity, requested_quantity, approved_quantity, packs_to_ship, price_per_pack, total_cost, total_received_quantity) li ON r.id::VARCHAR = li.requisition_id WITH DATA; -ALTER MATERIALIZED VIEW stock_status_and_consumption OWNER TO postgres; \ No newline at end of file +ALTER MATERIALIZED VIEW stock_status_and_consumption OWNER TO reporting; \ No newline at end of file diff --git a/reporting/docker-compose.yml b/reporting/docker-compose.yml index 993c6846..7fe56470 100644 --- a/reporting/docker-compose.yml +++ b/reporting/docker-compose.yml @@ -56,10 +56,10 @@ services: && openssl passwd -apr1 $NGINX_BASIC_AUTH_PW >> /etc/nginx/.htpasswd && sleep 120 && /home/run.sh" - logging: - driver: syslog - options: - syslog-address: "udp://127.0.0.1:${SYSLOG_UDP_PORT}" + # logging: + # driver: syslog + # options: + # syslog-address: "udp://127.0.0.1:${SYSLOG_UDP_PORT}" depends_on: [consul, log, config-container] nifi: @@ -71,32 +71,24 @@ services: bash -c "/config/nifi/scripts/start.sh ${OL_NIFI_VERSION} ${BASE_URL} ${USERNAME} ${PASSWORD} ${CLIENT_ID} ${CLIENT_SECRET} ${DB_PASSWORD} ${FHIR_ID} ${FHIR_PASSWORD}" environment: - NIFI_JVM_HEAP_MAX=${NIFI_JVM_HEAP_MAX} - logging: - driver: syslog - options: - syslog-address: "udp://127.0.0.1:${SYSLOG_UDP_PORT}" + # logging: + # driver: syslog + # options: + # syslog-address: "udp://127.0.0.1:${SYSLOG_UDP_PORT}" depends_on: [log, config-container, nginx] - db-config-container: - build: - context: ./db - volumes: - - db-config-volume:/docker-entrypoint-initdb.d db: image: openlmis/postgres:${OL_POSTGRES_VERSION} - env_file: ../settings.env + command: + "psql 'postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}' -f /var/lib/postgresql/data/OlmisCreateTableStatements.sql" volumes: - - db-config-volume:/docker-entrypoint-initdb.d - - dbdata:/var/lib/postgresql/data - environment: - - SUPERSET_POSTGRES_USER=${SUPERSET_POSTGRES_USER} - - SUPERSET_POSTGRES_PASSWORD=${SUPERSET_POSTGRES_PASSWORD} - logging: - driver: syslog - options: - syslog-address: "udp://127.0.0.1:${SYSLOG_UDP_PORT}" - depends_on: [log, consul, db-config-container] + - ./db/docker-entrypoint-initdb.d/templates:/var/lib/postgresql/data + # logging: + # driver: syslog + # options: + # syslog-address: "udp://127.0.0.1:${SYSLOG_UDP_PORT}" + depends_on: [log, consul] zookeeper: image: confluentinc/cp-zookeeper:${OL_ZOOKEEPER_VERSION} @@ -131,27 +123,31 @@ services: superset: build: context: ./superset + env_file: + - ./.env + environment: + - DATABASE_USERNAME=${DATABASE_USERNAME} + - DATABASE_PASSWORD=${DATABASE_PASSWORD} + - DATABASE_HOST=${DATABASE_HOST} + - DATABASE_PORT=${DATABASE_PORT} + - DATABASE_NAME=${DATABASE_NAME} volumes: - config-volume:/config + user: root command: > bash -c "cp -r /config/superset /etc/ + && apt-get update + && apt-get install -y postgresql-client && sleep 30 && fabmanager create-admin --app superset --username ${SUPERSET_ADMIN_USERNAME} --firstname Admin --lastname Admin --email noreply --password ${SUPERSET_ADMIN_PASSWORD} && superset db upgrade + && python3 /etc/superset/substitute_variables.py '/etc/superset/datasources/database.yaml' '/etc/superset/dashboards/openlmis_uat_dashboards.json' && superset import_datasources -p /etc/superset/datasources/database.yaml && superset import_dashboards -p /etc/superset/dashboards/openlmis_uat_dashboards.json && superset init && gunicorn -w 2 --timeout 60 -b 0.0.0.0:8088 --reload --limit-request-line 0 --limit-request-field_size 0 superset:app" - logging: - driver: syslog - options: - syslog-address: "udp://127.0.0.1:${SYSLOG_UDP_PORT}" - depends_on: [db, config-container, nginx] + depends_on: [config-container, nginx] volumes: syslog: external: false config-volume: - external: false - db-config-volume: - external: false - dbdata: external: false \ No newline at end of file