Skip to content

Commit

Permalink
Merge pull request #27 from questionlp/develop
Browse files Browse the repository at this point in the history
Prepare for Stats API v1.0 Deprecation and Deactivation
  • Loading branch information
questionlp authored Jan 29, 2023
2 parents 4db68f5 + b22804b commit 23df8ff
Show file tree
Hide file tree
Showing 32 changed files with 58 additions and 100 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changes

## 2.1.2

### Application Changes

- Add `/v1.0` and `/v1.0/docs` routes that redirect back to `/` as part of deprecating Stats API v1.0
- Remove links to Stats API v1.0 docs and update v1.0 deprecation message

## 2.1.1

### Application Changes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

The Stats API is written in Python and is built on [FastAPI](https://fastapi.tiangolo.com/) and provides endpoints that can be used to query guest, host, location, panelist, scorekeeper, and show data from a copy of the [Wait Wait Don't Tell Me! Stats database](https://github.com/questionlp/wwdtm_database).

If you're looking for the version 1.0 of the API, check out the [api.wwdt.me](https://github.com/questionlp/api.wwdt.me) repository.
Please note that version 1.0 of the Stats API has now been deprecated.

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""FastAPI application __init__.py for api.wwdt.me"""
4 changes: 2 additions & 2 deletions app/config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""Application Configuration"""

import json
from typing import Any, Dict

API_VERSION = "2.0"
APP_VERSION = "2.1.1"
APP_VERSION = "2.1.2"


def load_config(
Expand Down
15 changes: 12 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""FastAPI main application for api.wwdt.me"""

Expand Down Expand Up @@ -47,7 +47,6 @@
config = load_config()


# region Generic Routes
@app.get("/", include_in_schema=False, response_class=HTMLResponse)
@app.head("/", include_in_schema=False, response_class=HTMLResponse)
async def default_page(request: Request):
Expand Down Expand Up @@ -104,7 +103,17 @@ async def redoc_redirect_sub():
return RedirectResponse(f"/v{API_VERSION}/docs", status_code=301)


# endregion
@app.get("/v1.0", include_in_schema=False, response_class=RedirectResponse)
@app.head("/v1.0", include_in_schema=False, response_class=RedirectResponse)
async def api_v1_redirect():
return RedirectResponse("/", status_code=301)


@app.get("/v1.0/docs", include_in_schema=False, response_class=RedirectResponse)
@app.head("/v1.0/docs", include_in_schema=False, response_class=RedirectResponse)
async def api_v1_docs_redirect():
return RedirectResponse("/", status_code=301)


# Add the router modules for Guests, Hosts, Locations, Panelists,
# Scorekeepers, Shows and Version
Expand Down
2 changes: 1 addition & 1 deletion app/metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""FastAPI Metadata for api.wwdt.me"""

Expand Down
6 changes: 1 addition & 5 deletions app/models/guests.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""Guests Models"""

from typing import List, Optional, Union
from pydantic import BaseModel, conint, Field


# region Models
class Guest(BaseModel):
"""Not My Job Guest Information"""

Expand Down Expand Up @@ -69,6 +68,3 @@ class GuestsDetails(BaseModel):
"""List of Not My Job Guest Details"""

guests: List[GuestDetails] = Field(title="List of Guest Details")


# endregion
6 changes: 1 addition & 5 deletions app/models/hosts.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""Hosts Models"""

from typing import List, Optional, Union
from pydantic import BaseModel, conint, Field


# region Host Models
class Host(BaseModel):
"""Host Information"""

Expand Down Expand Up @@ -67,6 +66,3 @@ class HostsDetails(BaseModel):
"""List of Host Details"""

hosts: List[HostDetails] = Field(title="List of Host Details")


# endregion
6 changes: 1 addition & 5 deletions app/models/locations.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""Locations Models"""

from typing import List, Optional
from pydantic import BaseModel, conint, Field


# region Location Models
class Location(BaseModel):
"""Location Information"""

Expand Down Expand Up @@ -67,6 +66,3 @@ class LocationsDetails(BaseModel):
"""List of Location Details"""

locations: List[LocationDetails] = Field(title="List of Location Details")


# endregion
6 changes: 1 addition & 5 deletions app/models/panelists.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""Panelists Models"""

from typing import List, Optional, Tuple
from pydantic import BaseModel, conint, Field


# region Panelist Models
class Panelist(BaseModel):
"""Panelist Information"""

Expand Down Expand Up @@ -217,6 +216,3 @@ class PanelistScoresGroupedOrderedPair(BaseModel):
"number of times that score "
"has been earned",
)


# endregion
6 changes: 1 addition & 5 deletions app/models/scorekeepers.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""Scorekeepers Models"""

from typing import List, Optional, Union
from pydantic import BaseModel, conint, Field


# region Scorekeeper Models
class Scorekeeper(BaseModel):
"""Scorekeeper Information"""

Expand Down Expand Up @@ -70,6 +69,3 @@ class ScorekeepersDetails(BaseModel):
"""List of Scorekeeper Details"""

scorekeepers: List[ScorekeeperDetails] = Field(title="List of Scorekeeper Details")


# endregion
6 changes: 1 addition & 5 deletions app/models/shows.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""Shows Models"""

from typing import List, Optional, Union
from pydantic import BaseModel, conint, Field


# region Shows Models
class Show(BaseModel):
"""Show Information"""

Expand Down Expand Up @@ -133,6 +132,3 @@ class ShowDates(BaseModel):
"""List of Show Dates in ISO format (YYYY-MM-DD)"""

shows: List[str] = Field(title="List of Show Dates")


# endregion
6 changes: 1 addition & 5 deletions app/models/version.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""App Version Models"""

from pydantic import BaseModel, Field


# region App Version Models
class Version(BaseModel):
"""Wait Wait Stats API and Application Version Information"""

api: str = Field(title="Wait Wait Stats API Version")
app: str = Field(title="Application Version")
wwdtm: str = Field(title="wwdtm Version")


# endregion
2 changes: 1 addition & 1 deletion app/routers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""FastAPI application routers __init__.py for api.wwdt.me"""
2 changes: 1 addition & 1 deletion app/routers/guests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""API routes for Not My Job Guests endpoints"""

Expand Down
6 changes: 1 addition & 5 deletions app/routers/hosts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""API routes for Hosts endpoints"""

Expand All @@ -24,7 +24,6 @@
_database_connection = mysql.connector.connect(**_database_config)


# region Routes
@router.get(
"",
summary="Retrieve Information for All Hosts",
Expand Down Expand Up @@ -222,6 +221,3 @@ async def get_host_details_by_slug(host_slug: constr(strip_whitespace=True)):
detail="Database error occurred while trying to "
"retrieve host information",
)


# endregion
6 changes: 1 addition & 5 deletions app/routers/locations.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""API routes for Locations endpoints"""

Expand All @@ -24,7 +24,6 @@
_database_connection = mysql.connector.connect(**_database_config)


# region Routes
@router.get(
"",
summary="Retrieve Information for All Locations",
Expand Down Expand Up @@ -234,6 +233,3 @@ async def get_location_recordings_by_slug(location_slug: constr(strip_whitespace
detail="Database error occurred while trying to "
"retrieve location information",
)


# endregion
6 changes: 1 addition & 5 deletions app/routers/panelists.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""API routes for Panelists endpoints"""

Expand All @@ -27,7 +27,6 @@
_database_connection = mysql.connector.connect(**_database_config)


# region Routes
@router.get(
"",
summary="Retrieve Information for All Panelists",
Expand Down Expand Up @@ -483,6 +482,3 @@ async def get_panelist_scores_ordered_pair_by_slug(
detail="Database error occurred while trying to "
"retrieve panelist scores",
)


# endregion
6 changes: 1 addition & 5 deletions app/routers/scorekeepers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""API routes for Scorekeeper endpoints"""

Expand All @@ -24,7 +24,6 @@
_database_connection = mysql.connector.connect(**_database_config)


# region Routes
@router.get(
"",
summary="Retrieve Information for All Scorekeepers",
Expand Down Expand Up @@ -239,6 +238,3 @@ async def get_scorekeeper_details_by_slug(
detail="Database error occurred while trying to "
"retrieve scorekeeper information",
)


# endregion
6 changes: 1 addition & 5 deletions app/routers/shows.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# vim: set noai syntax=python ts=4 sw=4:
#
# Copyright (c) 2018-2022 Linh Pham
# Copyright (c) 2018-2023 Linh Pham
# api.wwdt.me is released under the terms of the Apache License 2.0
"""API routes for Scorekeeper endpoints"""

Expand All @@ -27,7 +27,6 @@
_database_connection = mysql.connector.connect(**_database_config)


# region Routes
@router.get(
"",
summary="Retrieve Information for All Shows",
Expand Down Expand Up @@ -627,6 +626,3 @@ async def get_shows_recent():
detail="Database error occurred while retrieving "
"shows from the database",
)


# endregion
Loading

0 comments on commit 23df8ff

Please sign in to comment.