feat: 계절 각 — 각마다 제철 달(months), 제철 각에 지금 계절 표시·철 지난 각은 순위 밖 맨 끝, 새 각 12개(꽃구경·이불빨래·빙수·실내건조·한강밤바람·단풍·억새·군고구마·해돋이·눈사람·붕어빵·귤까먹기), 해 뜰 무렵 시간대·일출 점수·눈 조건
This commit is contained in:
1 parent
43e1925d70
commit
5c05824ce0
14 files changed
+1130
-66
No files matched your search
@@ -17,7 +17,7 @@ def _summary(i: IndexItem, today: date) -> IndexSummary:
|
||||
d = i.definition
|
||||
return IndexSummary(
|
||||
index_id=d.index_id, code=d.code, name=d.name, icon=d.icon, category=IndexCategory(d.category), is_fun=d.is_fun,
|
||||
is_core=d.is_core, score=i.score.score, rank=i.rank, summary=i.score.summary,
|
||||
is_core=d.is_core, season=i.season, in_season=i.in_season, score=i.score.score, rank=i.rank, summary=i.score.summary,
|
||||
trend=[TrendPoint(day=t.score_date, label=slot_label(t.score_date, today), score=t.score, estimated=t.estimated) for t in i.trend],
|
||||
active=i.active, slot=i.slot, slots=[SlotPoint(slot=k, label=SLOT_LABEL[k], score=v) for k, v in i.slots.items()],
|
||||
)
|
||||
@@ -27,7 +27,7 @@ def _summary(i: IndexItem, today: date) -> IndexSummary:
|
||||
async def list_indices(
|
||||
region: str = Query(..., description="구 행정코드"),
|
||||
category: Optional[IndexCategory] = Query(None),
|
||||
core: bool = Query(False, description="이번 계절 핵심 지수만"),
|
||||
core: bool = Query(False, description="지금 제철인 각만"),
|
||||
service: IndexService = Depends(),
|
||||
) -> Res_IndexList:
|
||||
err, board = await service.board(region)
|
||||
@@ -35,7 +35,7 @@ async def list_indices(
|
||||
return Res_IndexList(result=error_info(err))
|
||||
items = [_summary(i, board.day) for i in board.items]
|
||||
top3 = [_summary(i, board.day) for i in board.ranked[:3]]
|
||||
filtered = [x for x in items if (category is None or x.category is category) and (not core or x.is_core)]
|
||||
filtered = [x for x in items if (category is None or x.category is category) and (not core or x.season)]
|
||||
return Res_IndexList(region_code=board.region.code, day=board.day, weather_score=board.weather_score, top3=top3, items=filtered)
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ class IndexSummary(WebPacketProtocol):
|
||||
category: IndexCategory
|
||||
is_fun: bool
|
||||
is_core: bool
|
||||
season: Optional[str] = Field(default=None, description="지금 제철이면 계절 이름(봄·여름·가을·겨울). 일 년 내내인 각은 없음")
|
||||
in_season: bool = Field(default=True, description="false 면 제철이 아니라 순위 밖, 목록 맨 끝")
|
||||
score: int
|
||||
rank: int
|
||||
summary: str
|
||||
|
||||
Reference in new issue
Block a user