Skip to content

Commit

Permalink
update to space v2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaney committed Oct 17, 2022
1 parent f3b99fe commit 4c4b064
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 130 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ on:

jobs:
test:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Checkout Repo
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.8

- name: Install Dependencies
run: |
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:

needs: test

runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Checkout Repo
Expand All @@ -84,7 +84,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: 3.8

- name: Publish to PyPi
uses: uw-it-aca/actions/publish-pypi@main
Expand Down
10 changes: 5 additions & 5 deletions uw_space/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 UW-IT, University of Washington
# Copyright 2022 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

import json
Expand All @@ -7,8 +7,8 @@
from uw_space.dao import SPACE_DAO
from uw_space.models import Facility

by_code_path = "/space/v1/facility.json?facility_code={}"
by_number_path = "/space/v1/facility/{}.json"
by_code_path = "/space/v2/facility.json?facility_code={}"
by_number_path = "/space/v2/facility/{}.json"
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -46,9 +46,9 @@ def search_by_number(self, facility_number):

def __process_json(self, json_data):
objs = []
facilitys = json_data.get("Facilitys")
facilitys = json_data.get("facilitys")
for facility in facilitys:
fnumber = facility.get("FacilityNumber")
fnumber = facility.get("facilityNumber")
if fnumber and len(fnumber):
fac = self.search_by_number(fnumber)
if fac:
Expand Down
2 changes: 1 addition & 1 deletion uw_space/dao.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 UW-IT, University of Washington
# Copyright 2022 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

from restclients_core.dao import DAO
Expand Down
27 changes: 9 additions & 18 deletions uw_space/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 UW-IT, University of Washington
# Copyright 2022 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

import json
Expand All @@ -22,23 +22,14 @@ def __init__(self, *args, **kwargs):
@staticmethod
def from_json(json_data):
obj = Facility()
obj.code = json_data.get("FacilityCode")
obj.number = json_data.get("FacilityNumber")
obj.last_updated = str_to_datetime(json_data.get("ModifiedDate"))
obj.name = json_data.get("LongName")

cpoint = json_data.get("CenterPoint")
if cpoint:
obj.latitude = cpoint.get("Latitude")
obj.longitude = cpoint.get("Longitude")
site_json = json_data.get("Site")

if site_json:
obj.site = site_json.get("Description")

ftype = json_data.get("FacilityType")
if ftype:
obj.type = ftype.get("Description")
obj.code = json_data.get("facilityCode")
obj.number = json_data.get("facilityNumber")
obj.last_updated = str_to_datetime(json_data.get("modifiedDate"))
obj.name = json_data.get("longName")
obj.latitude = json_data.get("mapUri", {}).get("latitude")
obj.longitude = json_data.get("mapUri", {}).get("longitude")
obj.site = json_data.get("site", {}).get("description")
obj.type = json_data.get("facilityType", {}).get("description")
return obj

def json_data(self):
Expand Down

This file was deleted.

45 changes: 0 additions & 45 deletions uw_space/resources/space/file/space/v1/facility/1347.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"metadata": "",
"pageCount": "1",
"previousPageStart": "",
"pageSize": "",
"pageStart": "",
"nextPageStart": "",
"pageStartOffset": 0,
"format": 1,
"xhtmlTitle": "",
"xhtmlPageStart": "",
"totalCount": 1,
"facilitys": [
{
"metadata": "",
"pageCount": "",
"previousPageStart": "",
"pageSize": "",
"pageStart": "",
"nextPageStart": "",
"totalCount": 1,
"pageStartOffset": 0,
"format": 1,
"facilityURI": {
"facilityNumber": "1347",
"facilityCode": "MEB",
"description": "Mechanical Engr Bldg",
"href": "/space/v2/facility/1347.json",
"viewFormat": 1
},
"facilityCode": "MEB",
"facilityNumber": "1347",
"facilityType": {
"metadata": "",
"pageCount": "",
"previousPageStart": "",
"pageSize": "",
"pageStart": "",
"nextPageStart": "",
"totalCount": 0,
"pageStartOffset": 0,
"format": 1,
"code": "MEB",
"description": ""
},
"status": "",
"aggregateFacilityNumber": "",
"site": "",
"name": "",
"longName": "",
"leasedOrOwned": "",
"streetAddress": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"countryCode2": "",
"countryCode3": "",
"county": "",
"repositoryTimeStamp": ""
}
],
"current": {
"xhtmlName": "",
"href": "/space/v2/facility.json?facility_type=&facility_code=MEB&status=&aggregate_number=&site=&name=&long_name=&leased_or_owned=&street=&city=&state=&postal_code=&page_start=1&page_size=10",
"facilityType": "",
"facilityCode": "MEB",
"status": "",
"aggregateNumber": "",
"site": "",
"name": "",
"longName": "",
"leasedOrOwned": "",
"street": "",
"city": "",
"state": "",
"postalCode": "",
"pageStart": "",
"pageSize": "",
"changedSinceDate": "",
"viewFormat": 1
},
"next": null,
"previous": null
}
92 changes: 92 additions & 0 deletions uw_space/resources/space/file/space/v2/facility/1347.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"metadata": "",
"pageCount": "",
"previousPageStart": "",
"pageSize": "",
"pageStart": "",
"nextPageStart": "",
"totalCount": 0,
"pageStartOffset": 0,
"format": 1,
"xhtmlTitle": "",
"addresses": [
{
"metadata": "",
"pageCount": "",
"previousPageStart": "",
"pageSize": "",
"pageStart": "",
"nextPageStart": "",
"totalCount": 0,
"pageStartOffset": 0,
"format": 1,
"code": "",
"primaryAddress": "",
"streetAddress": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"countryCode2": "",
"countryCode3": "",
"county": "17"
}
],
"aggregateFacilityNumber": "1347",
"facilityCode": "MEB",
"facilityNumber": "1347",
"facilityType": {
"code": "BLDG",
"description": "Building",
"href": ""
},
"grossSquareFeet": "97768",
"leasedOrOwned": "OWNED",
"longName": "Mechanical Engineering Building",
"modifiedDate": "3/27/2021 4:53:09 AM",
"name": "Mechanical Engr Bldg",
"site": {
"metadata": "",
"pageCount": "",
"previousPageStart": "",
"pageSize": "",
"pageStart": "",
"nextPageStart": "",
"totalCount": 0,
"pageStartOffset": 0,
"format": 1,
"code": "SEA_MN",
"description": "Seattle Main Campus"
},
"spaceUri": {
"xhtmlName": "",
"href": "",
"facilityCode": "MEB",
"facilityNumber": "1347",
"spaceNumber": "",
"primaryUse": "",
"primaryUseDescription": "",
"spaceUseCategory": "",
"spaceUseCategoryDescription": "",
"squareFeetLessThan": "",
"squareFeetGreaterThan": "",
"capacityLessThan": "",
"capacityGreaterThan": "",
"floorCode": "",
"orgCode": "",
"changedSinceDate": "",
"pageStart": "",
"pageSize": "",
"viewFormat": 1,
"isRestricted": true
},
"repositoryTimeStamp": "3/27/2021 4:53:09 AM",
"spaceCount": 252,
"status": "A",
"mapUri": {
"latitude": "47.653693",
"longitude": "-122.304747",
"href": "",
"viewFormat": 1
}
}
2 changes: 1 addition & 1 deletion uw_space/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 UW-IT, University of Washington
# Copyright 2022 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

# This is just a test runner for coverage
Expand Down
Loading

0 comments on commit 4c4b064

Please sign in to comment.