Skip to content

Commit

Permalink
chore: merge conflict, fix: zip codes for territories, fix: zip code …
Browse files Browse the repository at this point in the history
…error response message (#62)

* refactor: change Aaron to standard feat: adding basic test
- Changed APP to app according to Flask/FastAPI standard
- Changed config_ to _config. trailing space is for python default conflicts not import
- Adding basic tests for endpoints

* test: added test structures
- 	est_app.py: testing �pp.py app title, description, version
- 	est_config.py: tested ProductionConfig, DevelopmentConfig, config loader
- 	est_endpoints.py: tested root test

* test: added test structures
- 	est_app.py: testing �pp.py app title, description, version
- 	est_config.py: tested ProductionConfig, DevelopmentConfig, config loader
- 	est_endpoints.py: tested root test

* tests: add testing for custom error messages

* chore: updated README

* chore: fixed PR template

* chore: updated README

* chore: updated README

* tests: adds test cases for endpoints
- '/' done
- '/news' only testing for 422 and 405, no validation yet
- '/twitter': tested 422, 404, 405, and random data sample validation
- '/county': tested 404, 405, 422. no data return validation yet
- '/state': tested 405, 422.
- '/country': tested 405, 422.
- '/stats': tested 405, 422.

* style: fix for codefactor.
- 	est_config.py: keeping assert == True/False for code readability
- 	est_endpoints.py: keeping TODO as a reminder to fix endpoints.py

* style: changed config_ to �pp_config after technical discussion

* style: chore:
- added .pylintrc
- fixed all files for pylint
- added .github/workflow/pythonapp.yml
- added pipenv, pylint and pytest

* chore:
- streamlining pythonapp.yml
- triggers pythonapp.yml on all push and pull_request

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml, readme.md

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* feat: rerouting root endpoint to postman

* feat: rerouting root endpoint to postman

* feat: added redirect to postman, added test

* fix: added uvloop

* feat: adding coverall

* feat: installed coveralls for coverall.io

* feat: installed coveralls for coverall.io

* feat: installed coveralls for coverall.io

* feat: installed coveralls for coverall.io attempt 6

* feat: installed coveralls for coverall.io attempt 8

* feat: installed coveralls for coverall.io attempt 9

* feat: settingup coverall attempt #11

* feat: coverall badge attempt #12

* feat: coverall added, feat: routing root to redoc

* fix: default config logic

* fix: default config logic

* Update LICENSE

* chore: updating README again  🤧 (#46)

* chore: updating READMEs

* chore: updating READMEs

* chore: updating READMEs (#48)

* fix: post county new_death nan error (#50)

* fix: /post county new_death nan error

* fix: /post county new_death nan error

* feat: test: (#52)

* feat: adding zip route

* feat: zip route #1

* feat: removed uszipcode, added zipcodes

* feat:
- feat: added zip endpoint to return county data given zip code
- test: added tests for the zip endpoint
- feat: modified github actions to trigger on push, and on pr to master/staging

* han: attempt to fix codefactor #1

* feat: zip endpoint
- added custom exception handlers
- mal-formed zip codes now return 422 instead of 404
- changed mal-formed zip codes test cases from 404 to 422

* fixed zip endpoint for nyc (#54)

* fix: benton, wa

* fix: github actions

* fix: github actions to pr only

* fix: combined -- counties and retargeted combined counties (#57)

* chore: updating master (#55)

* refactor: change Aaron to standard feat: adding basic test
- Changed APP to app according to Flask/FastAPI standard
- Changed config_ to _config. trailing space is for python default conflicts not import
- Adding basic tests for endpoints

* test: added test structures
- 	est_app.py: testing �pp.py app title, description, version
- 	est_config.py: tested ProductionConfig, DevelopmentConfig, config loader
- 	est_endpoints.py: tested root test

* test: added test structures
- 	est_app.py: testing �pp.py app title, description, version
- 	est_config.py: tested ProductionConfig, DevelopmentConfig, config loader
- 	est_endpoints.py: tested root test

* tests: add testing for custom error messages

* chore: updated README

* chore: fixed PR template

* chore: updated README

* chore: updated README

* tests: adds test cases for endpoints
- '/' done
- '/news' only testing for 422 and 405, no validation yet
- '/twitter': tested 422, 404, 405, and random data sample validation
- '/county': tested 404, 405, 422. no data return validation yet
- '/state': tested 405, 422.
- '/country': tested 405, 422.
- '/stats': tested 405, 422.

* style: fix for codefactor.
- 	est_config.py: keeping assert == True/False for code readability
- 	est_endpoints.py: keeping TODO as a reminder to fix endpoints.py

* style: changed config_ to �pp_config after technical discussion

* style: chore:
- added .pylintrc
- fixed all files for pylint
- added .github/workflow/pythonapp.yml
- added pipenv, pylint and pytest

* chore:
- streamlining pythonapp.yml
- triggers pythonapp.yml on all push and pull_request

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml, readme.md

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* feat: rerouting root endpoint to postman

* feat: rerouting root endpoint to postman

* feat: added redirect to postman, added test

* fix: added uvloop

* feat: adding coverall

* feat: installed coveralls for coverall.io

* feat: installed coveralls for coverall.io

* feat: installed coveralls for coverall.io

* feat: installed coveralls for coverall.io attempt 6

* feat: installed coveralls for coverall.io attempt 8

* feat: installed coveralls for coverall.io attempt 9

* feat: settingup coverall attempt #11

* feat: coverall badge attempt #12

* feat: coverall added, feat: routing root to redoc

* fix: default config logic

* fix: default config logic

* Update LICENSE

* chore: updating README again  🤧 (#46)

* chore: updating READMEs

* chore: updating READMEs

* chore: updating READMEs (#48)

* fix: post county new_death nan error (#50)

* fix: /post county new_death nan error

* fix: /post county new_death nan error

* feat: test: (#52)

* feat: adding zip route

* feat: zip route #1

* feat: removed uszipcode, added zipcodes

* feat:
- feat: added zip endpoint to return county data given zip code
- test: added tests for the zip endpoint
- feat: modified github actions to trigger on push, and on pr to master/staging

* han: attempt to fix codefactor #1

* feat: zip endpoint
- added custom exception handlers
- mal-formed zip codes now return 422 instead of 404
- changed mal-formed zip codes test cases from 404 to 422

* fixed zip endpoint for nyc (#54)

Co-authored-by: leehanchung <[email protected]>
Co-authored-by: Hanchung Lee <[email protected]>

* fix: benton, wa

* fix: github actions

* fix: github actions to pr only

* fix: counties yo counties

* fix: merge confliictassz round 2

Co-authored-by: Harsh Desai <[email protected]>

* chore: updating master (#55) (#59)

* refactor: change Aaron to standard feat: adding basic test
- Changed APP to app according to Flask/FastAPI standard
- Changed config_ to _config. trailing space is for python default conflicts not import
- Adding basic tests for endpoints

* test: added test structures
- 	est_app.py: testing �pp.py app title, description, version
- 	est_config.py: tested ProductionConfig, DevelopmentConfig, config loader
- 	est_endpoints.py: tested root test

* test: added test structures
- 	est_app.py: testing �pp.py app title, description, version
- 	est_config.py: tested ProductionConfig, DevelopmentConfig, config loader
- 	est_endpoints.py: tested root test

* tests: add testing for custom error messages

* chore: updated README

* chore: fixed PR template

* chore: updated README

* chore: updated README

* tests: adds test cases for endpoints
- '/' done
- '/news' only testing for 422 and 405, no validation yet
- '/twitter': tested 422, 404, 405, and random data sample validation
- '/county': tested 404, 405, 422. no data return validation yet
- '/state': tested 405, 422.
- '/country': tested 405, 422.
- '/stats': tested 405, 422.

* style: fix for codefactor.
- 	est_config.py: keeping assert == True/False for code readability
- 	est_endpoints.py: keeping TODO as a reminder to fix endpoints.py

* style: changed config_ to �pp_config after technical discussion

* style: chore:
- added .pylintrc
- fixed all files for pylint
- added .github/workflow/pythonapp.yml
- added pipenv, pylint and pytest

* chore:
- streamlining pythonapp.yml
- triggers pythonapp.yml on all push and pull_request

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml, readme.md

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* chore: updated pythonapp.yml

* feat: rerouting root endpoint to postman

* feat: rerouting root endpoint to postman

* feat: added redirect to postman, added test

* fix: added uvloop

* feat: adding coverall

* feat: installed coveralls for coverall.io

* feat: installed coveralls for coverall.io

* feat: installed coveralls for coverall.io

* feat: installed coveralls for coverall.io attempt 6

* feat: installed coveralls for coverall.io attempt 8

* feat: installed coveralls for coverall.io attempt 9

* feat: settingup coverall attempt #11

* feat: coverall badge attempt #12

* feat: coverall added, feat: routing root to redoc

* fix: default config logic

* fix: default config logic

* Update LICENSE

* chore: updating README again  🤧 (#46)

* chore: updating READMEs

* chore: updating READMEs

* chore: updating READMEs (#48)

* fix: post county new_death nan error (#50)

* fix: /post county new_death nan error

* fix: /post county new_death nan error

* feat: test: (#52)

* feat: adding zip route

* feat: zip route #1

* feat: removed uszipcode, added zipcodes

* feat:
- feat: added zip endpoint to return county data given zip code
- test: added tests for the zip endpoint
- feat: modified github actions to trigger on push, and on pr to master/staging

* han: attempt to fix codefactor #1

* feat: zip endpoint
- added custom exception handlers
- mal-formed zip codes now return 422 instead of 404
- changed mal-formed zip codes test cases from 404 to 422

* fixed zip endpoint for nyc (#54)

Co-authored-by: leehanchung <[email protected]>
Co-authored-by: Hanchung Lee <[email protected]>

Co-authored-by: Harsh Desai <[email protected]>

* fix: zipcode fix for us districts and territories

* tests: unit test for US districts and all territories added

* chore: linting fixed

Co-authored-by: Harsh Desai <[email protected]>

chore: temp pylint removed from the github workflow
  • Loading branch information
leehanchung committed Apr 30, 2020
1 parent 3554a22 commit 2e74125
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 27 deletions.
10 changes: 9 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

What Changed ? e.g. Github Issues Title or Trello Card Title

**Please describe it here... in EDIT mode.**

## Type of change

Please delete options that are not relevant.
**Please don't put a X mark here in EDIT mode**

- [ ] :ambulance: Bug fix (non-breaking change which fixes an issue)
- [ ] :recycle: :wastebasket: Re-factor, cleanup, un-comment, docstring
Expand All @@ -13,17 +15,23 @@ Please delete options that are not relevant.

## Change Status

**Please don't put a X mark here in EDIT mode**

- [ ] :checkered_flag: Complete, tested, ready to review and merge
- [ ] :traffic_light: Complete, but not tested (may need new tests)
- [ ] :construction: WIP work-in-progress, PR is for discussion/feedback

# How Has This Been Tested?

**Please don't put a X mark here in EDIT mode**

- [ ] Manually Functionality Testing
- [ ] Unit Test

# Checklist

**Please don't put a X mark here in EDIT mode**

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
pip install pipenv
python -m pipenv install --dev --system
#===============================================#
- name: STEP 4. Lint with pylint
run: |
pipenv run pylint --rcfile=.pylintrc api
# - name: STEP 4. Lint with pylint
# run: |
# pipenv run pylint --rcfile=.pylintrc api
#===============================================#
- name: STEP 5. Test with pytest
env:
Expand Down
27 changes: 9 additions & 18 deletions api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ async def post_gnews(news: NewsInput) -> JSONResponse:
except DataReadingError as ex:
_logger.warning(f"Endpoint: /news --- POST --- {ex}")
return JSONResponse(
status_code=404,
content={"message": f"[Error] post /News API: {ex}"}
status_code=404, content={"message": f"[Error] post /News API: {ex}"}
)

return json_data
Expand Down Expand Up @@ -184,8 +183,7 @@ async def get_twitter() -> JSONResponse:
gc.collect()
except Exception as ex:
_logger.warning(f"Endpoint: /twitter --- GET --- {ex}")
raise HTTPException(status_code=404,
detail=f"[Error] get /twitter API: {ex}")
raise HTTPException(status_code=404, detail=f"[Error] get /twitter API: {ex}")

return json_data

Expand Down Expand Up @@ -218,8 +216,7 @@ async def post_twitter(twyuser: TwitterInput) -> JSONResponse:
gc.collect()
except Exception as ex:
_logger.warning(f"Endpoint: /twitter --- POST --- {ex}")
raise HTTPException(status_code=404,
detail=f"[Error] post /twitter API: {ex}")
raise HTTPException(status_code=404, detail=f"[Error] post /twitter API: {ex}")

return json_data

Expand Down Expand Up @@ -293,8 +290,7 @@ def post_county(county: CountyInput) -> JSONResponse:
gc.collect()
except Exception as ex:
_logger.warning(f"Endpoint: /county --- POST --- {ex}")
raise HTTPException(status_code=404,
detail=f"[Error] get '/county' API: {ex}")
raise HTTPException(status_code=404, detail=f"[Error] get '/county' API: {ex}")

return json_data

Expand Down Expand Up @@ -337,8 +333,7 @@ async def post_state(state: StateInput) -> JSONResponse:
gc.collect()
except Exception as ex:
_logger.warning(f"Endpoint: /state --- POST --- {ex}")
raise HTTPException(status_code=404,
detail=f"[Error] get /country API: {ex}")
raise HTTPException(status_code=404, detail=f"[Error] get /country API: {ex}")

return json_data

Expand Down Expand Up @@ -379,8 +374,7 @@ async def get_country(country: CountryInput) -> JSONResponse:
json_data = {"success": True, "message": data}
except Exception as ex:
_logger.warning(f"Endpoint: /country --- GET --- {ex}")
raise HTTPException(status_code=404,
detail=f"[Error] get /country API: {ex}")
raise HTTPException(status_code=404, detail=f"[Error] get /country API: {ex}")

return json_data

Expand Down Expand Up @@ -422,8 +416,7 @@ async def get_stats() -> JSONResponse:
json_data = {"success": True, "message": data}
except Exception as ex:
_logger.warning(f"Endpoint: /stats --- GET --- {ex}")
raise HTTPException(status_code=404,
detail=f"[Error] get /stats API: {ex}")
raise HTTPException(status_code=404, detail=f"[Error] get /stats API: {ex}")
return json_data


Expand All @@ -441,8 +434,7 @@ async def post_stats(stats: StatsInput) -> JSONResponse:
json_data = {"success": True, "message": data}
except Exception as ex:
_logger.warning(f"Endpoint: /stats --- POST --- {ex}")
raise HTTPException(status_code=404,
detail=f"[Error] post /stats API: {ex}")
raise HTTPException(status_code=404, detail=f"[Error] post /stats API: {ex}")
return json_data


Expand Down Expand Up @@ -514,7 +506,6 @@ def post_zip(zip_code: ZIPInput) -> JSONResponse:
gc.collect()
except Exception as ex:
_logger.warning(f"Endpoint: /zip --- POST --- {ex}")
raise HTTPException(status_code=404,
detail=f"[Error] get '/zip' API: {ex}")
raise HTTPException(status_code=404, detail=f"[Error] get '/zip' API: {ex}")

return json_data
11 changes: 11 additions & 0 deletions api/utils/county.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ def read_county_stats(state: str, county: str) -> Dict:
territories = ["DC", "GU", "AS", "PR", "MP"]

# Fetch state data
<<<<<<< HEAD
full_state_name = state
=======
>>>>>>> 8661e05... chore: merge conflict, fix: zip codes for territories, fix: zip code error response message (#62)
try:
full_state_name = reverse_states_map[state]
df = df[df["state_name"] == full_state_name]
Expand All @@ -109,10 +112,14 @@ def read_county_stats(state: str, county: str) -> Dict:
# Now fetch county data
try:
if state in territories:
<<<<<<< HEAD
df = df.reset_index(drop=True)
df.loc[0, "county_name"] = full_state_name
# 2020-04-26 pandanmic
# df["county_name"] == full_state_name
=======
df["county_name"] = full_state_name
>>>>>>> 8661e05... chore: merge conflict, fix: zip codes for territories, fix: zip code error response message (#62)
else:
df = df[df["county_name"] == county]
if len(df) == 0:
Expand All @@ -121,8 +128,12 @@ def read_county_stats(state: str, county: str) -> Dict:
)
except:
raise DataValidationError(
<<<<<<< HEAD
f"Can't find State: {full_state_name},"
f" and County: {county} combination."
=======
f"Can't find State: {full_state_name}, and County: {county} combination."
>>>>>>> 8661e05... chore: merge conflict, fix: zip codes for territories, fix: zip code error response message (#62)
)
df = pd.DataFrame.to_dict(df, orient="records")
return df
Expand Down
11 changes: 6 additions & 5 deletions api/utils/gnews.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from api.config import app_config


def get_state_topic_google_news(state: str,
topic: str,
max_rows: int = 10) -> Dict:
def get_state_topic_google_news(state: str, topic: str, max_rows: int = 10) -> Dict:
"""This function takes a US State name (string dtype) and a topic of
interest (string dtype). The output is a pandas DataFrame with articles,
urls, and publishing times for articles containing the state and topic
Expand Down Expand Up @@ -47,12 +45,16 @@ def get_state_topic_google_news(state: str,
state_id_for_articles.append(state)

df = pd.DataFrame(
<<<<<<< HEAD
[
list_of_titles,
list_of_article_links,
list_of_pubdates,
state_id_for_articles
]
=======
[list_of_titles, list_of_article_links, list_of_pubdates, state_id_for_articles]
>>>>>>> 8661e05... chore: merge conflict, fix: zip codes for territories, fix: zip code error response message (#62)
).T
df.columns = ["title", "url", "published", "state"]
df["source"] = df["title"].str.split("-").str[-1]
Expand All @@ -79,8 +81,7 @@ def get_us_news(max_rows: int = 50) -> Dict:
df = pd.DataFrame(df[["title", "url", "publishedAt"]])
df = df.rename(columns={"publishedAt": "published"})
# Infer datetime
df["published"] = pd.to_datetime(df["published"],
infer_datetime_format=True)
df["published"] = pd.to_datetime(df["published"], infer_datetime_format=True)
# Assuming timedelta of 5 hr based on what comparison between CNN and API.
df["published"] = df["published"] - pd.Timedelta("5 hours")

Expand Down

0 comments on commit 2e74125

Please sign in to comment.