Skip to content

Commit

Permalink
feat: 更新 dependencies 版本,改善 API 路徑 (#24)
Browse files Browse the repository at this point in the history
* build(deps): bump uvicorn from 0.23.2 to 0.24.0.post1

Bumps [uvicorn](https://github.com/encode/uvicorn) from 0.23.2 to 0.24.0.post1.
- [Release notes](https://github.com/encode/uvicorn/releases)
- [Changelog](https://github.com/encode/uvicorn/blob/master/CHANGELOG.md)
- [Commits](encode/uvicorn@0.23.2...0.24.0.post1)

---
updated-dependencies:
- dependency-name: uvicorn
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump pandas from 2.1.2 to 2.1.3

Bumps [pandas](https://github.com/pandas-dev/pandas) from 2.1.2 to 2.1.3.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Commits](pandas-dev/pandas@v2.1.2...v2.1.3)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* feat: 改善 API 路徑

將 /rpage 改成 /scrapers/rpage/announcements
將 /buses 裡面的 information 改成 info

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
l7wei and dependabot[bot] authored Nov 14, 2023
1 parent f64c5b3 commit 9fc4423
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 38 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
loguru==0.7.2
# Server
fastapi==0.104.1
uvicorn==0.23.2
uvicorn==0.24.0.post1
# Environment
python-dotenv==1.0.0
cachetools==5.3.2
Expand All @@ -11,7 +11,7 @@ pyopenssl==23.3.0
requests==2.31.0
beautifulsoup4==4.12.2
xmltodict==0.13.0
pandas==2.1.2
pandas==2.1.3
lxml==4.9.3
# Search
jieba==0.42.1
Expand Down
4 changes: 2 additions & 2 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
locations,
newsletters,
resources,
rpage,
scrapers,
)

app = FastAPI()
Expand All @@ -37,7 +37,7 @@ async def add_process_time_header(request: Request, call_next):
app.include_router(contacts.router, prefix="/phones", tags=["Phones"])
app.include_router(contacts.router, prefix="/contacts", tags=["Contacts"])
app.include_router(resources.router, prefix="/resources", tags=[])
app.include_router(rpage.router, prefix="/rpage", tags=["Rpage"])
app.include_router(scrapers.router, prefix="/scrapers", tags=["Scrapers"])


@app.get(
Expand Down
52 changes: 22 additions & 30 deletions src/api/routers/buses.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ async def get_main():
return buses.get_main_data()


@router.get(
"/main/information/toward_tsmc_building_info", response_model=schemas.buses.BusInfo
)
@router.get("/main/info/toward_main_gate", response_model=schemas.buses.BusInfo)
async def get_tsmc_building_toward_main_gate_info() -> schemas.buses.BusInfo:
"""
台積館往校門口公車資訊。
"""
return buses.get_main_data()["toward_main_gate_info"]


@router.get("/main/info/toward_tsmc_building", response_model=schemas.buses.BusInfo)
async def get_main_gate_toward_tsmc_building_info() -> schemas.buses.BusInfo:
"""
校門口往台積館公車資訊。
Expand All @@ -27,13 +33,16 @@ async def get_main_gate_toward_tsmc_building_info() -> schemas.buses.BusInfo:


@router.get(
"/main/information/toward_main_gate_info", response_model=schemas.buses.BusInfo
"/main/schedules/weekday/toward_main_gate",
response_model=list[schemas.buses.BusMainSchedule],
)
async def get_tsmc_building_toward_main_gate_info() -> schemas.buses.BusInfo:
async def get_main_weekday_bus_schedule_toward_main_gate() -> list[
schemas.buses.BusMainSchedule
]:
"""
台積館往校門口公車資訊。
台積館往校門口公車時刻表(平日)
"""
return buses.get_main_data()["toward_main_gate_info"]
return buses.get_main_data()["weekday_bus_schedule_toward_main_gate"]


@router.get(
Expand All @@ -50,16 +59,16 @@ async def get_main_weekday_bus_schedule_toward_tsmc_building() -> list[


@router.get(
"/main/schedules/weekday/toward_main_gate",
"/main/schedules/weekend/toward_main_gate",
response_model=list[schemas.buses.BusMainSchedule],
)
async def get_main_weekday_bus_schedule_toward_main_gate() -> list[
async def get_main_weekend_bus_schedule_toward_main_gate() -> list[
schemas.buses.BusMainSchedule
]:
"""
台積館往校門口公車時刻表(平日)
台積館往校門口公車時刻表(假日)。
"""
return buses.get_main_data()["weekday_bus_schedule_toward_main_gate"]
return buses.get_main_data()["weekend_bus_schedule_toward_main_gate"]


@router.get(
Expand All @@ -75,19 +84,6 @@ async def get_main_weekend_bus_schedule_toward_tsmc_building() -> list[
return buses.get_main_data()["weekend_bus_schedule_toward_TSMC_building"]


@router.get(
"/main/schedules/weekend/toward_main_gate",
response_model=list[schemas.buses.BusMainSchedule],
)
async def get_main_weekend_bus_schedule_toward_main_gate() -> list[
schemas.buses.BusMainSchedule
]:
"""
台積館往校門口公車時刻表(假日)。
"""
return buses.get_main_data()["weekend_bus_schedule_toward_main_gate"]


####################################################################################################
@router.get("/nanda", response_model=schemas.buses.BusNandaData)
async def get_nanda():
Expand All @@ -97,19 +93,15 @@ async def get_nanda():
return buses.get_nanda_data()


@router.get(
"/nanda/information/toward_main_campus", response_model=schemas.buses.BusInfo
)
@router.get("/nanda/info/toward_main_campus", response_model=schemas.buses.BusInfo)
async def get_nanda_toward_main_campus_info() -> schemas.buses.BusInfo:
"""
南大往本部區間車資訊。
"""
return buses.get_nanda_data()["toward_main_campus_info"]


@router.get(
"/nanda/information/toward_south_campus", response_model=schemas.buses.BusInfo
)
@router.get("/nanda/info/toward_south_campus", response_model=schemas.buses.BusInfo)
async def get_nanda_toward_south_campus_info() -> schemas.buses.BusInfo:
"""
本部往南大區間車資訊。
Expand Down
9 changes: 5 additions & 4 deletions src/api/routers/rpage.py → src/api/routers/scrapers.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from typing import Optional

from fastapi import APIRouter, Path
from pydantic import BaseModel, Field, HttpUrl
from pydantic import HttpUrl

from src.api import schemas
from src.utils.scrapers import rpage_scraper

router = APIRouter()


@router.get("/{full_path:path}", response_model=list[schemas.resources.RssData])
@router.get(
"/rpage/announcements/{full_path:path}",
response_model=list[schemas.resources.RssData],
)
def get_rpage_data(
full_path: HttpUrl = Path(
...,
Expand Down

0 comments on commit 9fc4423

Please sign in to comment.