Skip to content

Commit d1cb0d3

Browse files
authored
Conversion to Graph Database (#407)
* Conversion to graph-based data model: Stage 1 - Convert to graph-based data model - Update requirements - Todo: Update API to support db changes - Todo: Complete the data model conversion - Todo: remove SQLAlchemy * Add NeoModel models Convert routes to use neomodel instead of SQLAlchemy * Replace PGSQL with Neo4j in the backend - Update docker-compose.yml to use the new neo4j container - Make additional corrections to the db models Additionally: Change env variable w/PDT to NPDI Our env vars will be changing anyway, so we might as well make this change now. * Update .env template * Update Config/ENV values * Remove SQL Alchemy code * Removed Sqlalchemy refrences. * Update requirements * Remove Alembic * Update DB Models - Add suffix to officer names - Add type and subtype to allegations - Add record ID to allegation and complaint - Allow for multiple agencies with the same name * Add request validation * Update Auth API endpoints * Implement paginated responses Implement hidden fields Implement serialization of Node properties - Note: This is a WIP * Move Neomodel class extensions to schemas.py * Update Partners API and fix errors - Get all partners - Get partner by ID - Create partner * Fix error in `to_dict()` * Updated Officer APIs - Get officer by ID - Get all officers - Create officer Fix error in officer model Add enum property for Partner MemberRole * Handle Node updates * Add Update to routes - officers - agencies - partners Fix temporary pydantic schema for agencies * Specify versions for core dependencies * Attempting to add a test DB * Disable flake8 (temp) * Update reqs + Test tests * Remove unused tests * Add app fixture * Retry Test Github action Update deprecated syntax Update Status codes and responses for register_user * Change id to element_id for Cypher queries. Update `test_register` and auth `resgister` route * Update Front end registration page to match API * Add local test DB * Update requirements * Update Auth tests * Add Testcleanup function Update reqs * Fix failing Agency endpoint tests * Fix officer tests * Fix Partner endpoint tests Note: Leaving out the invitation and joining tests for now * Skipping officer employment tests for now. This will require a larger feature change. * Add Test Marker to GH test DB * Use health check to seed test DB * Revert Health Check hack... * Update test db URI * Update frontend user db object conections * Update Jest tests * Disable frontend tests * Flake8 tests * Convert Partner -> Source * Update Readme to explain tests * JSONSerializable.to_dict() fixed for relationships Added full address to Units Added Hispanic/Latino to ethnicity * Add Cardinality to Officer, Agency, and Unit relationships * Make `StructuredRel`s JSON serializable * Add citations to officers, units, and agencies
1 parent 63506a4 commit d1cb0d3

File tree

102 files changed

+4378
-5266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+4378
-5266
lines changed

.env.template

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
POSTGRES_USER=postgres
2-
POSTGRES_PASSWORD=postgres
3-
POSTGRES_DB=police_data
4-
POSTGRES_HOST=db
5-
PGPORT=5432
6-
PDT_API_PORT=5000
1+
GRAPH_USER=neo4j
2+
GRAPH_PASSWORD=password
3+
GRAPH_DB=police_data
4+
GRAPH_URI=db
5+
GRAPH_NM_URI=db:7687
6+
GRAPH_PORT=5432
7+
NPDI_API_PORT=5000
78
MIXPANEL_TOKEN=your_mixpanel_token
9+
MAIL_SERVER=mail.yourdomain.com
10+
MAIL_PORT=465
11+
MAIL_USE_SSL=true

.github/workflows/frontend-checks.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,3 @@ jobs:
2828
- name: Formatting
2929
if: always()
3030
run: npm run check-formatting
31-
32-
- name: Jest Tests
33-
if: always()
34-
run: npm run test
35-
36-
- name: Types
37-
if: always()
38-
run: npm run check-types

.github/workflows/python-tests.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
services:
11-
postgres:
12-
image: postgres:16-alpine
11+
test_db:
12+
image: neo4j:5.23-community
1313
env:
14-
POSTGRES_USER: postgres
15-
POSTGRES_PASSWORD: postgres
16-
POSTGRES_DB: police_data_test
14+
NEO4J_AUTH: neo4j/test_pwd
15+
ports:
16+
- 7688:7687
1717
options: >-
18-
--health-cmd pg_isready
18+
--health-cmd "cypher-shell -u neo4j -p test_pwd 'RETURN 1'"
1919
--health-interval 10s
2020
--health-timeout 5s
2121
--health-retries 5
22-
ports:
23-
- 5432:5432
2422
steps:
2523
- uses: actions/checkout@v4
2624
- name: Python 3.12 Setup
@@ -38,7 +36,10 @@ jobs:
3836
- name: Run tests
3937
run: python -m pytest
4038
env:
41-
POSTGRES_USER: postgres
42-
POSTGRES_PASSWORD: postgres
43-
POSTGRES_DB: police_data
39+
GRAPH_USER: neo4j
40+
GRAPH_PASSWORD: test_pwd
41+
GRAPH_TEST_URI: localhost:7688
4442
MIXPANEL_TOKEN: mixpanel_token
43+
- name: Output Neo4j logs
44+
if: failure()
45+
run: docker logs $(docker ps -q --filter ancestor=neo4j:5.23-community)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ flake8 backend/
8282
python -m pytest
8383
```
8484

85+
For more information on running the tests, see the [backend tests README](./backend/tests/README.md)
86+
8587
### Front End Tests
8688

8789
The current frontend tests can be found in the GitHub Actions workflow file [frontend-checks.yml](https://github.com/codeforboston/police-data-trust/blob/0488d03c2ecc01ba774cf512b1ed2f476441948b/.github/workflows/frontend-checks.yml)

alembic.ini

Lines changed: 0 additions & 87 deletions
This file was deleted.

alembic/__init__.py

Whitespace-only changes.

alembic/dev_seeds.py

Lines changed: 0 additions & 181 deletions
This file was deleted.

0 commit comments

Comments
 (0)