Skip to content

Commit

Permalink
Merge pull request #975 from hackforla/mattyweb/issue971
Browse files Browse the repository at this point in the history
Mattyweb/issue971
  • Loading branch information
mattyweb authored Mar 1, 2021
2 parents 97511c4 + f4d0a31 commit 48be8c8
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 152 deletions.
1 change: 1 addition & 0 deletions .github/workflows/create_release_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
echo GITHUB_SHA=${{ github.sha }} >> server/api/.env
echo DEBUG=True >> server/api/.env
echo DB_ECHO=True >> server/api/.env
echo API_ALLOWED_ORIGINS=[https://dev.311-data.org,http://localhost:3000,https://311-data.matt-webster.net] >> server/api/.env
- name: Build and Push Image to Docker Hub
uses: docker/build-push-action@v1
with:
Expand Down
202 changes: 101 additions & 101 deletions server/api/alembic/seeds/councils.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def upgrade():
sa.Column('type_name', sa.VARCHAR(), nullable=False),
sa.Column('agency_id', sa.SMALLINT(), nullable=False),
sa.Column('color', sa.VARCHAR()),
sa.Column('data_code', sa.VARCHAR(), nullable=False),
sa.Column('sort_order', sa.SMALLINT())
sa.Column('data_code', sa.VARCHAR(), index=True, nullable=False),
)

with open(DATA_FOLDER + 'request_types.csv') as f:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def upgrade():
sa.Column('twitter', sa.VARCHAR()),
sa.Column('region_id', sa.SMALLINT(), index=True, nullable=False),
sa.Column('latitude', sa.FLOAT(), nullable=True),
sa.Column('longitude', sa.FLOAT(), nullable=True)
sa.Column('longitude', sa.FLOAT(), nullable=True),
sa.Column('data_code', sa.SMALLINT(), index=True, nullable=False)
)

with open(DATA_FOLDER + 'councils.csv') as f:
Expand Down
6 changes: 3 additions & 3 deletions server/api/alembic/versions/f605be47c1ec_add_agencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@
requests.closeddate::DATE as closed_date,
request_types.type_id as type_id,
agencies.agency_id,
COALESCE(requests.nc, 0)::SMALLINT as council_id,
COALESCE(councils.council_id, 0)::SMALLINT as council_id,
COALESCE(councils.region_id, 0)::SMALLINT as region_id,
requests.address::VARCHAR(100),
requests.latitude,
requests.longitude,
requests.cd::SMALLINT as city_id
FROM
requests
requests
LEFT JOIN
request_types on requests.requesttype = request_types.data_code
LEFT JOIN
councils on requests.nc = councils.council_id
councils on requests.nc = councils.data_code
LEFT JOIN
agencies on requests.owner = agencies.data_code
WHERE
Expand Down
2 changes: 1 addition & 1 deletion server/api/code/lacity_data_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# string array of allows client URLs
API_ALLOWED_ORIGINS = config(
"API_ALLOWED_ORIGINS",
default=["http://localhost:3000", "https://dev.311-data.org"]
default=["https://www.311-data.org", "https://dev.311-data.org"]
)

# getting database configuration
Expand Down
4 changes: 2 additions & 2 deletions server/api/tests/integration/test_api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def test_councils(client):


def test_council(client):
url = "/councils/6"
url = "/councils/1"
response = client.get(url)
assert response.status_code == 200
assert response.json()["councilName"] == "Arleta"


def test_council_open_counts(client):
url = "/councils/6/counts/open/types"
url = "/councils/1/counts/open/types"
response = client.get(url)
assert response.status_code == 200
assert len(response.json()) == 1
Expand Down
20 changes: 10 additions & 10 deletions server/api/tests/integration/test_api_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ def test_service_requests_start(client):
url = "/requests?start_date=2020-01-01"
response = client.get(url)
assert response.status_code == 200
assert len(response.json()) == 9910
assert len(response.json()) == 9989


def test_service_requests_end(client):
url = "/requests?start_date=2020-01-01&end_date=2020-01-02"
response = client.get(url)
assert response.status_code == 200
assert len(response.json()) == 8240
assert len(response.json()) == 8304


def test_service_requests_type(client):
url = "/requests?start_date=2020-01-01&end_date=2020-01-02&type_id=2"
response = client.get(url)
assert response.status_code == 200
assert len(response.json()) == 297
assert len(response.json()) == 298


def test_service_requests_council(client):
url = "/requests?start_date=2020-01-01&end_date=2020-01-02&council_id=4"
url = "/requests?start_date=2020-01-01&end_date=2020-01-02&council_id=27"
response = client.get(url)
assert response.status_code == 200
assert len(response.json()) == 55


def test_service_requests_all(client):
url = "/requests?start_date=2020-01-01&end_date=2020-01-02&type_id=2&council_id=4"
url = "/requests?start_date=2020-01-01&end_date=2020-01-02&type_id=2&council_id=27"
response = client.get(url)
assert response.status_code == 200
assert len(response.json()) == 6
Expand All @@ -45,11 +45,11 @@ def test_updated_service_requests(client):
url = "/requests/updated?start_date=2020-01-01&end_date=2020-01-02"
response = client.get(url)
assert response.status_code == 200
assert len(response.json()) == 9715
assert len(response.json()) == 9792


def test_updated_service_requests_council(client):
url = "/requests/updated?start_date=2020-01-01&end_date=2020-01-02&council_id=4"
url = "/requests/updated?start_date=2020-01-01&end_date=2020-01-02&council_id=27"
response = client.get(url)
assert response.status_code == 200
assert len(response.json()) == 64
Expand All @@ -64,7 +64,7 @@ def test_service_request(client):
assert response.json()["typeName"] == "Illegal Dumping"
assert response.json()["agencyId"] == 2
assert response.json()["agencyName"] == "Sanitation Bureau"
assert response.json()["councilId"] == 19
assert response.json()["councilId"] == 44
assert response.json()["councilName"] == "Lake Balboa"
assert response.json()["createdDate"] == "2020-01-01"
assert response.json()["closedDate"] == "2020-01-02"
Expand Down Expand Up @@ -95,7 +95,7 @@ def test_service_request_pins(client):
"startDate": "2020-01-01",
"endDate": "2020-01-02",
"ncList": [
29
40
],
"requestTypes": [
4
Expand All @@ -113,7 +113,7 @@ def test_service_request_points(client):
"startDate": "2020-01-01",
"endDate": "2020-01-02",
"ncList": [
29
40
],
"requestTypes": [
4
Expand Down
64 changes: 32 additions & 32 deletions server/api/tests/integration/test_api_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ def test_map_pins(client):
"startDate": "01/01/2020",
"endDate": "01/02/2020",
"ncList": [
29,
30,
9,
14,
16,
32,
33,
34,
46,
52,
54,
55,
58,
60,
76,
97,
104,
119,
121,
128
37,
38,
40,
41,
42,
47,
50,
62,
63,
68,
91,
92,
96
],
"requestTypes": [
"Dead Animal Removal",
Expand Down Expand Up @@ -66,23 +66,23 @@ def test_visualizations(client):
"startDate": "01/01/2020",
"endDate": "01/02/2020",
"ncList": [
29,
30,
9,
14,
16,
32,
33,
34,
46,
52,
54,
55,
58,
60,
76,
97,
104,
119,
121,
128
37,
38,
40,
41,
42,
47,
50,
62,
63,
68,
91,
92,
96
],
"requestTypes": [
"Bulky Items",
Expand Down

0 comments on commit 48be8c8

Please sign in to comment.