feat: 로딩 스켈레톤·행사 사진·전시·주말 예상 점수·노을 탭 재정리 등 화면 전반 개선
- 화면 전체 스켈레톤, 로딩·완료·실패 사이 레이아웃 고정, 값 없음은 '?' - 행사 사진·출처 표시, 문화정보 API 전시 연결, 행사 30km 거리 기준 - 각 상세 점수 칸 오늘/내일/토/일, 단기예보 밖 주말은 중기예보 예상 점수 - 6각 차트 축 이름을 좋은 방향으로, 계산 근거 문구 정리 - 아이콘 오용·뜻 모를 표시·빈 데이터·포스트 본문 반복 수정 - 미세먼지 별도 포스트, 노을 명소 전국 155곳 거리 기준, 노을 탭 결론 중심 재구성 - 밤 다크 테마·별똥별, 댓글·좋아요 대기·실패 표시 - 주말 전국 랭킹·당일치기 카드, 계절 이야기 사진 수집 - 문서: 포스트 타입별 내용, 각 데이터 정리, TODO 진행 순서
This commit is contained in:
1 parent
296a09d6db
commit
ddf05aeb5c
97 files changed
+5475
-720
No files matched your search
@@ -34,6 +34,8 @@ class RowsSlide(WebPacketProtocol):
|
||||
line: str
|
||||
icon: str
|
||||
rows: list[Row] = []
|
||||
image: Optional[str] = None # 있으면 아이콘 대신 카드 전체에 사진
|
||||
image_credit: Optional[str] = None # 사진 출처 표기 ("ⓒ한국관광공사")
|
||||
|
||||
|
||||
class GakSlide(WebPacketProtocol):
|
||||
@@ -67,16 +69,40 @@ class WeekDay(WebPacketProtocol):
|
||||
weekday: str
|
||||
icon: str
|
||||
text: str
|
||||
temp_min_c: Optional[float] = None
|
||||
temp_max_c: Optional[float] = None
|
||||
rain_prob: Optional[int] = None
|
||||
|
||||
|
||||
class WeekSlide(WebPacketProtocol):
|
||||
"""주말 예보: 토·일 비교 + 옷차림·우산 팁."""
|
||||
|
||||
kind: Literal["week"]
|
||||
eyebrow: str
|
||||
line: str
|
||||
days: list[WeekDay]
|
||||
tip: Optional[str] = None
|
||||
|
||||
|
||||
Slide = Annotated[Union[HoursSlide, RowsSlide, GakSlide, SunsetSlide, WeekSlide], Field(discriminator="kind")]
|
||||
class PlanStep(WebPacketProtocol):
|
||||
time: str
|
||||
icon: str
|
||||
title: str
|
||||
sub: str
|
||||
image: Optional[str] = None # 행사 사진
|
||||
image_credit: Optional[str] = None
|
||||
|
||||
|
||||
class PlanSlide(WebPacketProtocol):
|
||||
"""주말 플랜: 그날 시간대별 동선."""
|
||||
|
||||
kind: Literal["plan"]
|
||||
eyebrow: str
|
||||
line: str
|
||||
steps: list[PlanStep]
|
||||
|
||||
|
||||
Slide = Annotated[Union[HoursSlide, RowsSlide, GakSlide, SunsetSlide, WeekSlide, PlanSlide], Field(discriminator="kind")]
|
||||
|
||||
|
||||
class PostData(WebPacketProtocol):
|
||||
@@ -124,6 +150,8 @@ class BandEvent(WebPacketProtocol):
|
||||
name: str
|
||||
status_label: str
|
||||
icon: str
|
||||
image: Optional[str] = None
|
||||
image_credit: Optional[str] = None
|
||||
|
||||
|
||||
class BandArticle(WebPacketProtocol):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, Path, Query
|
||||
@@ -5,20 +6,18 @@ from fastapi import APIRouter, Depends, Path, Query
|
||||
from common.enums import ErrorType, IndexCategory
|
||||
from common.models.errors import error_info
|
||||
from router.v1.index.protocol import Factor, IndexSummary, Res_IndexDetail, Res_IndexList, TrendPoint
|
||||
from services.calc.index_calc import AXES, zero_rules_text
|
||||
from services.index_service import IndexItem, IndexService
|
||||
from services.calc.index_calc import AXES, axis_label, zero_rules_text
|
||||
from services.index_service import IndexItem, IndexService, slot_label
|
||||
|
||||
router = APIRouter(prefix="/v1/index", tags=["index"])
|
||||
|
||||
_AXIS_LABEL = {"temp": "기온", "rain": "비", "wind": "바람", "humidity": "습도", "air": "공기", "time": "시간대"}
|
||||
|
||||
|
||||
def _summary(i: IndexItem) -> IndexSummary:
|
||||
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,
|
||||
trend=[TrendPoint(day=t.score_date, score=t.score) for t in i.trend],
|
||||
trend=[TrendPoint(day=t.score_date, label=slot_label(t.score_date, today), score=t.score, estimated=t.estimated) for t in i.trend],
|
||||
)
|
||||
|
||||
|
||||
@@ -32,7 +31,7 @@ async def list_indices(
|
||||
err, board = await service.board(region)
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return Res_IndexList(result=error_info(err))
|
||||
items = [_summary(i) for i in board.items]
|
||||
items = [_summary(i, board.day) for i in board.items]
|
||||
filtered = [x for x in items if (category is None or x.category is category) and (not core or x.is_core)]
|
||||
return Res_IndexList(region_code=board.region.code, day=board.day, weather_score=board.weather_score, top3=items[:3], items=filtered)
|
||||
|
||||
@@ -47,10 +46,11 @@ async def get_index(index_id: int = Path(...), region: str = Query(..., descript
|
||||
return Res_IndexDetail(result=error_info(ErrorType.NOT_FOUND))
|
||||
d, s = item.definition, item.score
|
||||
return Res_IndexDetail(
|
||||
index=_summary(item), description=d.description,
|
||||
index=_summary(item, board.day), description=d.description,
|
||||
factors=[
|
||||
Factor(axis=a, label=_AXIS_LABEL[a], value=getattr(s, f"{a}_score"), weight=getattr(d, f"weight_{a}"), note=s.notes.get(a, ""))
|
||||
Factor(axis=a, label=axis_label(a, d.factor_rules), value=getattr(s, f"{a}_score"), weight=getattr(d, f"weight_{a}"), note=s.notes.get(a, ""))
|
||||
for a in AXES
|
||||
if getattr(d, f"weight_{a}")
|
||||
],
|
||||
zero_rules=zero_rules_text(d.zero_rules), zero_reason=s.zero_reason, limit=d.limit_description,
|
||||
)
|
||||
@@ -1,13 +1,17 @@
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from common.enums import IndexCategory
|
||||
from common.models.gmodel import Res_WebPacketProtocol, WebPacketProtocol
|
||||
|
||||
|
||||
class TrendPoint(WebPacketProtocol):
|
||||
day: date
|
||||
label: str = Field(description="칸 이름: 오늘 / 내일 / 토 10.10")
|
||||
score: int
|
||||
estimated: bool = Field(description="시간별 예보가 없어 중기예보로 낸 예상 점수")
|
||||
|
||||
|
||||
class IndexSummary(WebPacketProtocol):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from datetime import date, datetime
|
||||
from typing import Optional
|
||||
from typing import Literal, Optional
|
||||
|
||||
from common.enums import Confidence, SkyGrade, SkyType
|
||||
from common.models.gmodel import Res_WebPacketProtocol, WebPacketProtocol
|
||||
@@ -30,6 +30,25 @@ class SpotData(WebPacketProtocol):
|
||||
distance_km: float
|
||||
|
||||
|
||||
class PlanSpot(WebPacketProtocol):
|
||||
name: str
|
||||
distance_km: float
|
||||
|
||||
|
||||
class SkyPlanData(WebPacketProtocol):
|
||||
day: date
|
||||
when: str
|
||||
verdict: Literal["go", "maybe", "rest"]
|
||||
headline: str
|
||||
reason: str
|
||||
score: int
|
||||
grade_label: str
|
||||
best_at: Optional[datetime] = None
|
||||
spot: Optional[PlanSpot] = None
|
||||
timeline: list[BestTime] = []
|
||||
outlook: str = ""
|
||||
|
||||
|
||||
class Res_Sky(Res_WebPacketProtocol):
|
||||
region_code: Optional[str] = None
|
||||
sunset_azimuth: Optional[int] = None
|
||||
@@ -37,6 +56,7 @@ class Res_Sky(Res_WebPacketProtocol):
|
||||
sunrise: Optional[SkyScoreData] = None
|
||||
days: list[SkyScoreData] = []
|
||||
spots: list[SpotData] = []
|
||||
plan: Optional[SkyPlanData] = None
|
||||
|
||||
|
||||
class RankData(WebPacketProtocol):
|
||||
|
||||
@@ -4,9 +4,9 @@ from common.database.model.models import SkyScore
|
||||
from common.enums import Confidence, ErrorType, SkyGrade, SkyType
|
||||
from common.models.errors import error_info
|
||||
from common.utils.kma_time import now_kst
|
||||
from router.v1.sky.protocol import BestTime, RankData, Res_Sky, Res_SkyRanking, SkyScoreData, SpotData
|
||||
from router.v1.sky.protocol import BestTime, PlanSpot, RankData, Res_Sky, Res_SkyRanking, SkyPlanData, SkyScoreData, SpotData
|
||||
from services.calc.sky_score import GRADE_LABEL
|
||||
from services.sky_service import SkyService
|
||||
from services.sky_service import SkyPlan, SkyService
|
||||
|
||||
router = APIRouter(prefix="/v1/sky", tags=["sky"])
|
||||
|
||||
@@ -18,7 +18,15 @@ def _score(x: SkyScore) -> SkyScoreData:
|
||||
)
|
||||
|
||||
|
||||
@router.get("", response_model=Res_Sky, response_model_exclude_none=True, summary="노을·일출 점수, 3컷, 가까운 명소, 앞으로 3일")
|
||||
def _plan(p: SkyPlan) -> SkyPlanData:
|
||||
return SkyPlanData(
|
||||
day=p.day, when=p.when, verdict=p.verdict, headline=p.headline, reason=p.reason, score=p.score, grade_label=p.grade_label,
|
||||
best_at=p.best_at, spot=PlanSpot(name=p.spot.spot.name, distance_km=p.spot.distance_km) if p.spot else None,
|
||||
timeline=[BestTime(**b) for b in p.timeline], outlook=p.outlook,
|
||||
)
|
||||
|
||||
|
||||
@router.get("", response_model=Res_Sky, response_model_exclude_none=True, summary="노을 결론(나가 볼 만한지·왜·언제 어디로), 시간표, 앞으로 3일, 가까운 명소")
|
||||
async def get_sky(region: str = Query(..., description="구 행정코드"), service: SkyService = Depends()) -> Res_Sky:
|
||||
err, view = await service.view(region)
|
||||
if err is not ErrorType.SUCCESS:
|
||||
@@ -31,6 +39,7 @@ async def get_sky(region: str = Query(..., description="구 행정코드"), serv
|
||||
SpotData(no=i + 1, name=s.spot.name, description=s.spot.description, lat=float(s.spot.lat), lon=float(s.spot.lon), distance_km=s.distance_km)
|
||||
for i, s in enumerate(view.spots)
|
||||
],
|
||||
plan=_plan(view.plan) if view.plan else None,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,32 @@ class EventData(WebPacketProtocol):
|
||||
status: str
|
||||
status_label: str
|
||||
fit: Optional[str] = None
|
||||
image: Optional[str] = None
|
||||
image_credit: Optional[str] = None # 사진 출처 표기 ("ⓒ한국관광공사")
|
||||
|
||||
|
||||
class Res_EventList(Res_WebPacketProtocol):
|
||||
events: list[EventData] = []
|
||||
|
||||
|
||||
class WeekRankItem(WebPacketProtocol):
|
||||
rank: int
|
||||
region_code: str
|
||||
name: str
|
||||
score: int # 나들이 날씨 점수 (낮 10~17시)
|
||||
reason: str # 근거 한 줄 ("비 10% · 체감 21° · 맑음")
|
||||
icon: str
|
||||
temp_min_c: Optional[float] = None
|
||||
temp_max_c: Optional[float] = None
|
||||
rain_prob: int
|
||||
estimated: bool # 단기예보 밖이라 중기예보로 어림한 점수
|
||||
|
||||
|
||||
class WeekRankDay(WebPacketProtocol):
|
||||
day: date
|
||||
weekday: str
|
||||
items: list[WeekRankItem] = []
|
||||
|
||||
|
||||
class Res_WeekRanking(Res_WebPacketProtocol):
|
||||
days: list[WeekRankDay] = []
|
||||
@@ -6,10 +6,14 @@ from fastapi import APIRouter, Depends, Query
|
||||
from common.enums import ErrorType
|
||||
from common.models.errors import error_info
|
||||
from common.utils.kma_time import now_kst
|
||||
from router.v1.week.protocol import DayData, EventData, PlaceData, Res_EventList, Res_PlaceList, Res_Week
|
||||
from services.week_service import WeekService
|
||||
from router.v1.week.protocol import (
|
||||
DayData, EventData, PlaceData, Res_EventList, Res_PlaceList, Res_Week, Res_WeekRanking, WeekRankDay, WeekRankItem,
|
||||
)
|
||||
from services.week_service import WeekService, image_credit
|
||||
from services.weekend_rank import WeekendRank, rank_days, weekend_days
|
||||
|
||||
router = APIRouter(prefix="/v1/week", tags=["week"])
|
||||
_WEEKDAY_KO = ("월", "화", "수", "목", "금", "토", "일")
|
||||
|
||||
|
||||
@router.get("", response_model=Res_Week, response_model_exclude_none=True, summary="7일 날씨와 그날 추천")
|
||||
@@ -22,6 +26,25 @@ async def get_week(region: str = Query(..., description="구 행정코드"), ser
|
||||
])
|
||||
|
||||
|
||||
@router.get("/ranking", response_model=Res_WeekRanking, response_model_exclude_none=True, summary="이번 주말 전국 나들이 날씨 순위 (대표 30곳)")
|
||||
async def get_week_ranking() -> Res_WeekRanking:
|
||||
service = WeekendRank()
|
||||
err, scores = await service.scores()
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return Res_WeekRanking(result=error_info(err))
|
||||
err, regions, _ = await service.targets()
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return Res_WeekRanking(result=error_info(err))
|
||||
by_code = {r.code: r for r in regions}
|
||||
return Res_WeekRanking(days=[
|
||||
WeekRankDay(day=d, weekday=_WEEKDAY_KO[d.weekday()], items=[
|
||||
WeekRankItem(rank=i + 1, name=by_code[x.region_code].name, **{k: v for k, v in x.__dict__.items() if k != "day"})
|
||||
for i, x in enumerate(items)
|
||||
])
|
||||
for d, items in rank_days(scores, set(by_code), weekend_days(now_kst().date()))
|
||||
])
|
||||
|
||||
|
||||
@router.get("/place/list", response_model=Res_PlaceList, response_model_exclude_none=True, summary="날씨 맞춤 데이트 명소")
|
||||
async def list_places(
|
||||
region: str = Query(...), day: Optional[date] = Query(None, description="기본은 오늘"), area: Optional[str] = Query(None),
|
||||
@@ -50,6 +73,7 @@ async def list_events(region: str = Query(...), area: Optional[str] = Query(None
|
||||
EventData(
|
||||
event_id=i.event.event_id, name=i.event.name, place_name=i.event.place_name, icon=i.event.icon, start_date=i.event.start_date,
|
||||
end_date=i.event.end_date, is_confirmed=i.event.is_confirmed, status=i.status, status_label=i.status_label, fit=i.fit,
|
||||
image=i.event.image_url, image_credit=image_credit(i.event),
|
||||
)
|
||||
for i in items
|
||||
])
|
||||
Reference in new issue
Block a user