From c3adb142d83cfa222dcc538d3d9f4ffc42081282 Mon Sep 17 00:00:00 2001 From: Jan Romaniak Date: Tue, 24 Dec 2024 11:13:35 +0100 Subject: [PATCH] change to use replica db (#4530) * skip unstable * STG // Fix RDI import dmd json field (#4504) * fix rdi import dmd data json * add migration * fix test * imports * more fixes * remove generateroles from upgrade, update generateroles based on admin history for these roles * [STG] Payment Plan export xlsx: added FSP template doc types list (#4508) * upd get_column_value_from_payment & fsp template doc types * document_types :star: * fix :star2: * Dashboard fix * 215787_drop_cash_assist_migration_script_fix (#4509) * 2226242_Payment_verification_page_not_accessible (#4514) * add correct permission for cycles page * fe fix * just new line * AB#226656 Error Cannot read properties of undefined Grievance ticket * change to use replica db * fix tests --------- Co-authored-by: pavlo-mk Co-authored-by: Domenico Co-authored-by: Paulina Kujawa Co-authored-by: Paulina Kujawa <42150286+pkujawa@users.noreply.github.com> Co-authored-by: Allan Stockman Rugano Co-authored-by: Marek Biczysko <34810846+MarekBiczysko@users.noreply.github.com> Co-authored-by: Allan Stockman RUGANO Co-authored-by: Maciej Szewczyk --- .github/helpers/.env-selenium | 1 + .github/helpers/.env-unit | 1 + development_tools/.env.example | 1 + development_tools/local_selenium_init.sh | 1 + src/frontend/data/schema.graphql | 2 +- src/frontend/src/__generated__/graphql.tsx | 13 +++++++++++-- src/hct_mis_api/config/env.py | 7 +++++++ src/hct_mis_api/config/settings.py | 10 +--------- 8 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/helpers/.env-selenium b/.github/helpers/.env-selenium index 053211d707..c0c20daafe 100644 --- a/.github/helpers/.env-selenium +++ b/.github/helpers/.env-selenium @@ -7,5 +7,6 @@ CELERY_RESULT_BACKEND=redis://redis:6379/0 CACHE_LOCATION=redis://redis:6379/1 CONSTANCE_REDIS_CONNECTION=redis://redis:6379/0 DATABASE_URL=postgis://postgres:postgres@db:5432/postgres +REP_DATABASE_URL=postgis://postgres:postgres@db:5432/postgres USE_DUMMY_EXCHANGE_RATES=yes CELERY_TASK_ALWAYS_EAGER=true \ No newline at end of file diff --git a/.github/helpers/.env-unit b/.github/helpers/.env-unit index 2d9b12ce49..f4d9629157 100644 --- a/.github/helpers/.env-unit +++ b/.github/helpers/.env-unit @@ -4,6 +4,7 @@ POSTGRES_DB=postgres POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres DATABASE_URL=postgis://postgres:postgres@db:5432/postgres +REP_DATABASE_URL=postgis://postgres:postgres@db:5432/postgres POSTGRES_SSL_MODE=off EMAIL_HOST=TBD EMAIL_HOST_USER=TBD diff --git a/development_tools/.env.example b/development_tools/.env.example index 8fb7fa57a3..039f56c32a 100644 --- a/development_tools/.env.example +++ b/development_tools/.env.example @@ -10,6 +10,7 @@ POSTGRES_PASS=postgres PGUSER=postgres POSTGRES_HOST_AUTH_METHOD=trust DATABASE_URL=postgis://postgres:postgres@db:5432/postgres +REP_DATABASE_URL=postgis://postgres:postgres@db:5432/postgres POSTGRES_SSL_MODE=off EMAIL_HOST=TBD EMAIL_HOST_USER=TBD diff --git a/development_tools/local_selenium_init.sh b/development_tools/local_selenium_init.sh index 435ae593e7..941c04b063 100755 --- a/development_tools/local_selenium_init.sh +++ b/development_tools/local_selenium_init.sh @@ -11,6 +11,7 @@ export POSTGRES_PASS=postgres export PGUSER=postgres export POSTGRES_HOST_AUTH_METHOD=trust export DATABASE_URL=postgis://postgres:postgres@localhost:5432/postgres +export REP_DATABASE_URL=postgis://postgres:postgres@localhost:5432/postgres export POSTGRES_SSL_MODE=off export EMAIL_HOST=TBD export EMAIL_HOST_USER=TBD diff --git a/src/frontend/data/schema.graphql b/src/frontend/data/schema.graphql index a4d8f3a996..19ac5b1a5d 100644 --- a/src/frontend/data/schema.graphql +++ b/src/frontend/data/schema.graphql @@ -2536,7 +2536,7 @@ type PaymentNode implements Node { isCashAssist: Boolean! followUps(offset: Int, before: String, after: String, first: Int, last: Int): PaymentNodeConnection! householdSnapshot: PaymentHouseholdSnapshotNode - paymentVerification: PaymentVerificationNode + paymentVerifications(offset: Int, before: String, after: String, first: Int, last: Int): PaymentVerificationNodeConnection! ticketComplaintDetails(offset: Int, before: String, after: String, first: Int, last: Int): TicketComplaintDetailsNodeConnection! ticketSensitiveDetails(offset: Int, before: String, after: String, first: Int, last: Int): TicketSensitiveDetailsNodeConnection! adminUrl: String diff --git a/src/frontend/src/__generated__/graphql.tsx b/src/frontend/src/__generated__/graphql.tsx index 5c1110a8bb..2cf5624f5a 100644 --- a/src/frontend/src/__generated__/graphql.tsx +++ b/src/frontend/src/__generated__/graphql.tsx @@ -4206,7 +4206,7 @@ export type PaymentNode = Node & { paymentPlanHardConflictedData?: Maybe>>; paymentPlanSoftConflicted?: Maybe; paymentPlanSoftConflictedData?: Maybe>>; - paymentVerification?: Maybe; + paymentVerifications: PaymentVerificationNodeConnection; program?: Maybe; reasonForUnsuccessfulPayment?: Maybe; serviceProvider?: Maybe; @@ -4241,6 +4241,15 @@ export type PaymentNodeFollowUpsArgs = { }; +export type PaymentNodePaymentVerificationsArgs = { + after?: InputMaybe; + before?: InputMaybe; + first?: InputMaybe; + last?: InputMaybe; + offset?: InputMaybe; +}; + + export type PaymentNodeTicketComplaintDetailsArgs = { after?: InputMaybe; before?: InputMaybe; @@ -25264,7 +25273,7 @@ export type PaymentNodeResolvers>>, ParentType, ContextType>; paymentPlanSoftConflicted?: Resolver, ParentType, ContextType>; paymentPlanSoftConflictedData?: Resolver>>, ParentType, ContextType>; - paymentVerification?: Resolver, ParentType, ContextType>; + paymentVerifications?: Resolver>; program?: Resolver, ParentType, ContextType>; reasonForUnsuccessfulPayment?: Resolver, ParentType, ContextType>; serviceProvider?: Resolver, ParentType, ContextType>; diff --git a/src/hct_mis_api/config/env.py b/src/hct_mis_api/config/env.py index e23d2865d2..65ca70a9bc 100644 --- a/src/hct_mis_api/config/env.py +++ b/src/hct_mis_api/config/env.py @@ -11,6 +11,13 @@ "", "https://django-environ.readthedocs.io/en/latest/types.html#environ-env-db-url", ), + "REP_DATABASE_URL": ( + str, + "sqlite://", + "", + "", + "https://django-environ.readthedocs.io/en/latest/types.html#environ-env-db-url", + ), "DEBUG": (bool, False), "ENV": (str, "dev"), "DOMAIN": (str, "localhost:8000"), diff --git a/src/hct_mis_api/config/settings.py b/src/hct_mis_api/config/settings.py index 9590f71859..5f2f88890a 100644 --- a/src/hct_mis_api/config/settings.py +++ b/src/hct_mis_api/config/settings.py @@ -10,7 +10,6 @@ from django.utils.translation import gettext_lazy as _ from single_source import get_version -from smart_env.exceptions import SmartEnvMissing from hct_mis_api.config.env import env @@ -110,15 +109,8 @@ else: EMAIL_SUBJECT_PREFIX = "" -try: - REPLICA_DB = env("REP_DATABASE_URL", default=None) -except SmartEnvMissing: - REPLICA_DB = None -if REPLICA_DB: - RO_CONN = dict(**env.db("REP_DATABASE_URL")).copy() -else: - RO_CONN = dict(**env.db("DATABASE_URL")).copy() +RO_CONN = env.db("REP_DATABASE_URL") RO_CONN.update( { "OPTIONS": {"options": "-c default_transaction_read_only=on"},