Skip to content

Commit

Permalink
Merge pull request #137 from OCHA-DAP/dev
Browse files Browse the repository at this point in the history
PR for bringing dev into prod
  • Loading branch information
alexandru-m-g authored Jun 5, 2024
2 parents 5ebeeae + 4b5e413 commit 6982eda
Show file tree
Hide file tree
Showing 193 changed files with 6,353 additions and 2,903 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ venv/
coverage.xml

*.pg_restore

5 changes: 3 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"console": "integratedTerminal",
"justMyCode": true,
}
]
}
],

}
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

The Humanitarian API (HAPI) is being developed by a team from the [Centre for Humanitarian Data](https://centre.humdata.org/).
The Humanitarian API (HDX HAPI) is being developed by a team from the [Centre for Humanitarian Data](https://centre.humdata.org/).

HDX developers are using [Visual Code](https://code.visualstudio.com/) as a standard IDE for this project with development taking place inside Docker containers.

Expand All @@ -26,15 +26,15 @@ docker-compose exec -T hapi sh -c "pytest --log-level=INFO --cov=. --cov-report

As an integration test the `docs` endpoint is inspected "manually".

A local copy of HAPI can be run by importing a snapshot of the database using the following shell script invocation in the host machine.
A local copy of HDX HAPI can be run by importing a snapshot of the database using the following shell script invocation in the host machine.

```shell
./restore_database.sh https://github.com/OCHA-DAP/hapi-pipelines/raw/db-export/database/hapi_db.pg_restore hapi
```

The HAPI application can then be launched using the `start` launch configuration in Visual Code, this serves the documentation at `http://localhost:8844/docs` and the API at `http://localhost:8844/api` in the host machine.
The HDX HAPI application can then be launched using the `start` launch configuration in Visual Code, this serves the documentation at `http://localhost:8844/docs` and the API at `http://localhost:8844/api` in the host machine.

The HAPI database can be accessed locally with the following connection details:
The HDX HAPI database can be accessed locally with the following connection details:

```
URL: jdbc:postgresql://localhost:45432/hapi
Expand Down
20 changes: 10 additions & 10 deletions alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
from hdx_hapi.db.models.base import Base
from hapi_schema.db_admin1 import DBAdmin1
from hapi_schema.db_admin2 import DBAdmin2
from hapi_schema.db_location import DBLocation
from hapi_schema.db_age_range import DBAgeRange
from hapi_schema.db_gender import DBGender
from hapi_schema.db_dataset import DBDataset
from hapi_schema.db_resource import DBResource
from hapi_schema.db_org import DBOrg
from hapi_schema.db_org_type import DBOrgType
from hapi_schema.db_sector import DBSector
from hapi_schema.db_food_security import DBFoodSecurity
from hapi_schema.db_gender import DBGender
from hapi_schema.db_humanitarian_needs import DBHumanitarianNeeds
from hapi_schema.db_ipc_phase import DBIpcPhase
from hapi_schema.db_ipc_type import DBIpcType
from hapi_schema.db_location import DBLocation
from hapi_schema.db_national_risk import DBNationalRisk
from hapi_schema.db_population_group import DBPopulationGroup
from hapi_schema.db_population_status import DBPopulationStatus

from hapi_schema.db_operational_presence import DBOperationalPresence
from hapi_schema.db_org import DBOrg
from hapi_schema.db_org_type import DBOrgType
from hapi_schema.db_patch import DBPatch
from hapi_schema.db_population import DBPopulation
from hapi_schema.db_population_group import DBPopulationGroup
from hapi_schema.db_population_status import DBPopulationStatus
from hapi_schema.db_resource import DBResource
from hapi_schema.db_sector import DBSector

target_metadata = Base.metadata
# target_metadata = None
Expand All @@ -56,7 +56,7 @@ def _get_db_uri() -> str:
db_url = db_url_dict.get('sqlalchemy.url') if db_url_dict else None
if not db_url:
db_url = f'postgresql+psycopg2://{create_pg_uri_from_env_without_protocol()}'
# print(f'My db url is {x_url}')
# print(f'My db url is {db_url}')
return db_url


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""create views
Revision ID: 5ea413542a49
Revises: be60e42db4db
Create Date: 2023-09-07 20:31:02.198042
Revision ID: 2d6db74775b5
Revises: 927d2ce143cc
Create Date: 2024-04-25 15:02:49.678672
"""
from typing import Sequence, Union
Expand All @@ -22,31 +22,44 @@
from hapi_schema.db_location import view_params_location
from hapi_schema.db_national_risk import view_params_national_risk
from hapi_schema.db_operational_presence import view_params_operational_presence
from hapi_schema.db_org_type import view_params_org_type
from hapi_schema.db_org import view_params_org
from hapi_schema.db_org_type import view_params_org_type
from hapi_schema.db_population import view_params_population
from hapi_schema.db_population_group import view_params_population_group
from hapi_schema.db_population_status import view_params_population_status
from hapi_schema.db_population import view_params_population
from hapi_schema.db_resource import view_params_resource
from hapi_schema.db_sector import view_params_sector

from hdx_hapi.db.models.views.util.util import CreateView, DropView


# revision identifiers, used by Alembic.
revision: str = '5ea413542a49'
down_revision: Union[str, None] = 'be60e42db4db'
revision: str = '2d6db74775b5'
down_revision: Union[str, None] = '927d2ce143cc'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


VIEW_LIST = [
view_params_admin1, view_params_admin2, view_params_age_range, view_params_dataset,
view_params_food_security, view_params_gender, view_params_humanitarian_needs,
view_params_ipc_phase, view_params_ipc_type, view_params_location, view_params_national_risk,
view_params_operational_presence, view_params_org_type, view_params_org,
view_params_population_group, view_params_population_status, view_params_population,
view_params_resource, view_params_sector
view_params_admin1,
view_params_admin2,
view_params_age_range,
view_params_dataset,
view_params_food_security,
view_params_gender,
view_params_humanitarian_needs,
view_params_ipc_phase,
view_params_ipc_type,
view_params_location,
view_params_national_risk,
view_params_operational_presence,
view_params_org_type,
view_params_org,
view_params_population_group,
view_params_population_status,
view_params_population,
view_params_resource,
view_params_sector,
]


Expand All @@ -57,5 +70,4 @@ def upgrade() -> None:

def downgrade() -> None:
for v in VIEW_LIST:
op.get_bind().execute(DropView(v.name))

op.get_bind().execute(DropView(v.name))
Loading

0 comments on commit 6982eda

Please sign in to comment.