diff --git a/backend/router/v1/watch/protocol.py b/backend/router/v1/watch/protocol.py
index 9a7fac7..b957944 100644
--- a/backend/router/v1/watch/protocol.py
+++ b/backend/router/v1/watch/protocol.py
@@ -27,6 +27,13 @@ class WatchSlot(WebPacketProtocol):
rain_prob: Optional[int] = None
+class WatchEvent(WebPacketProtocol):
+ name: str
+ place_name: str
+ status_label: str
+ fit: Optional[str] = None
+
+
class WatchTimeline(WebPacketProtocol):
start_at: datetime
kind: Literal["gak", "sunset"]
@@ -45,3 +52,4 @@ class Res_WatchSummary(Res_WebPacketProtocol):
sunset: Optional[WatchSunset] = None
slots: list[WatchSlot] = []
timeline: list[WatchTimeline] = []
+ events: list[WatchEvent] = []
diff --git a/backend/router/v1/watch/watch.py b/backend/router/v1/watch/watch.py
index 757d34f..ff82612 100644
--- a/backend/router/v1/watch/watch.py
+++ b/backend/router/v1/watch/watch.py
@@ -1,4 +1,5 @@
import asyncio
+import re
from datetime import datetime, timedelta
from typing import Optional
@@ -6,9 +7,10 @@ from fastapi import APIRouter, Depends, Query
from common.database.model.models import SkyScore
from common.enums import ErrorType, SkyGrade
+from common.logger import LOG
from common.models.errors import error_info
from common.utils.kma_time import KST, now_kst
-from router.v1.watch.protocol import Res_WatchSummary, WatchNow, WatchSlot, WatchSunset, WatchTimeline
+from router.v1.watch.protocol import Res_WatchSummary, WatchEvent, WatchNow, WatchSlot, WatchSunset, WatchTimeline
from services.calc.sky_score import GRADE_LABEL
from services.calc.sun import sun_times
from services.feed_service import _SUNSET_FULL, _top, feed_ttl_sec, slot_of
@@ -16,18 +18,32 @@ from services.index_service import IndexService
from services.now_service import NowService
from services.sky_service import SkyService
from services.weather_service import WeatherService
+from services.week_service import EventItem, WeekService
router = APIRouter(prefix="/v1/watch", tags=["watch"])
MAX_PICKS = 3
# 워치 스킨이 큰 원(1위) + 둘레 링 6개(2~7위)를 채운다
TOP_N = 7
+MAX_EVENTS = 2
+# 워치 readTimeout(10초) 안에 끝나도록. 첫 조회라 TourAPI 를 부르다 늦으면 이번 요약엔 축제를 빼고, 캐시는 다음 조회가 채운다
+EVENTS_TIMEOUT_SEC = 4
+# "[하트하트아트앤컬처] 마음의 각도" 처럼 이름 앞 주최·분류 괄호. 워치 칸이 좁아 뺀다
+_NAME_PREFIX = re.compile(r"^(\[[^\]]*\]\s*)+")
def _best(score: SkyScore, kind: str) -> datetime:
return datetime.fromisoformat(next(b["at"] for b in score.best_times if b["kind"] == kind)).astimezone(KST)
+async def _events(week: WeekService, region: str) -> tuple[ErrorType, list[EventItem]]:
+ try:
+ return await asyncio.wait_for(week.events(region, None), EVENTS_TIMEOUT_SEC)
+ except TimeoutError:
+ LOG.warning(f"[watch] events {region}: {EVENTS_TIMEOUT_SEC}초 넘어 생략")
+ return ErrorType.EXTERNAL_API_ERROR, []
+
+
def timeline(now: datetime, sunset: Optional[SkyScore], is_today: bool) -> list[WatchTimeline]:
"""컴플리케이션이 언제 무엇을 보여줄지. 오늘 노을이 볼 만하면(60점 이상) 일몰 2시간 전부터 보랏빛 하늘까지 노을, 나머지는 각."""
if sunset is None or not is_today or sunset.score < _SUNSET_FULL:
@@ -47,9 +63,10 @@ async def get_watch_summary(
now_service: NowService = Depends(),
sky: SkyService = Depends(),
index: IndexService = Depends(),
+ week: WeekService = Depends(),
) -> Res_WatchSummary:
- (err_t, today), (err_n, now_w), (err_s, view), (err_i, board) = await asyncio.gather(
- weather.today(region), now_service.now(region), sky.view(region), index.board(region),
+ (err_t, today), (err_n, now_w), (err_s, view), (err_i, board), (err_e, events) = await asyncio.gather(
+ weather.today(region), now_service.now(region), sky.view(region), index.board(region), _events(week, region),
)
today = today if err_t is ErrorType.SUCCESS else None
now_w = now_w if err_n is ErrorType.SUCCESS else None
@@ -95,4 +112,11 @@ async def get_watch_summary(
sunset_at=_best(target, "sun"), best_at=_best(target, "peak"),
)
res.timeline = timeline(now, target, is_today)
+ # 축제를 못 가져와도 요약은 그대로 낸다 (err_e 면 빈 목록)
+ if err_e is ErrorType.SUCCESS:
+ res.events = [
+ WatchEvent(name=_NAME_PREFIX.sub("", i.event.name) or i.event.name, place_name=i.event.place_name, status_label=i.status_label, fit=i.fit)
+ # 진행 중인 행사를 먼저 (스킨은 첫 번째 하나만 보여 준다). 같은 상태 안에서는 서버 순서(가까운 날짜·거리) 그대로
+ for i in sorted(events, key=lambda i: i.status != "live")[:MAX_EVENTS]
+ ]
return res
diff --git a/backend/tests/test_watch.py b/backend/tests/test_watch.py
index e22bb28..0f51b5b 100644
--- a/backend/tests/test_watch.py
+++ b/backend/tests/test_watch.py
@@ -4,7 +4,8 @@ from types import SimpleNamespace
import pytest
from httpx import ASGITransport, AsyncClient
-from common.utils.kma_time import KST
+import services.week_service as week_service
+from common.utils.kma_time import KST, now_kst
from router.router import app
from router.v1.watch.watch import timeline
@@ -12,6 +13,10 @@ REGION = "1141000000"
SUN = datetime(2026, 10, 6, 18, 0, tzinfo=KST)
+async def _async(v):
+ return v
+
+
def _sunset(score: int) -> SimpleNamespace:
return SimpleNamespace(score=score, best_times=[
{"at": SUN.isoformat(), "kind": "sun", "label": "해 져요"},
@@ -53,6 +58,21 @@ async def test_watch_summary_bundles_now_top_picks_sunset(offline):
assert body["sunset"]["best_at"] > body["sunset"]["sunset_at"]
assert all(s["at"] > body["issued_at"] for s in body["slots"])
assert body["timeline"][0]["start_at"] == body["issued_at"]
+ assert [(e["name"], e["status_label"]) for e in body["events"]] == [("테스트 축제", "진행 중")]
+
+
+@pytest.mark.anyio
+async def test_watch_summary_puts_live_event_first_without_bracket_prefix(offline, monkeypatch):
+ # 서버 순서는 시작일이 가까운 순이라 내일 시작이 먼저지만, 스킨에 하나만 띄우니 진행 중을 앞으로. 이름 앞 [주최] 는 뺀다
+ today = now_kst().date()
+ day = lambda n: (today + timedelta(days=n)).strftime("%Y%m%d")
+ monkeypatch.setattr(week_service, "fetch_festivals", lambda c, sido, since: _async([
+ {"contentid": "1", "title": "내일 축제", "addr1": "서울", "eventstartdate": day(1), "eventenddate": day(2)},
+ {"contentid": "2", "title": "[주최] 열리는 축제", "addr1": "서울", "eventstartdate": day(-3), "eventenddate": day(2)},
+ ] if sido == "11" else []))
+ async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
+ body = (await client.get("/v1/watch/summary", params={"region": REGION})).json()
+ assert [e["name"] for e in body["events"]] == ["열리는 축제", "내일 축제"]
@pytest.mark.anyio
diff --git a/watch/app/src/main/AndroidManifest.xml b/watch/app/src/main/AndroidManifest.xml
index 01402e0..ec1e0a5 100644
--- a/watch/app/src/main/AndroidManifest.xml
+++ b/watch/app/src/main/AndroidManifest.xml
@@ -140,6 +140,20 @@
+
+
+
+
+
+
+
+
+
Unit) {
@@ -72,6 +72,7 @@ private fun App(s: Summary?, loading: Boolean, opened: String?, onRetry: () -> U
add(Page.SKY)
if (s.top.isNotEmpty()) add(Page.TOP)
if (s.picks.isNotEmpty()) add(Page.PICKS)
+ if (s.events.isNotEmpty()) add(Page.EVENTS)
if (s.sunset != null) add(Page.SUNSET)
if (s.slots.isNotEmpty()) add(Page.HOURS)
}
@@ -83,6 +84,7 @@ private fun App(s: Summary?, loading: Boolean, opened: String?, onRetry: () -> U
Page.SKY -> SkyPage(s, now)
Page.TOP -> GakListPage("오늘의 각", s.top.take(3), bgButter, medals = true, now)
Page.PICKS -> GakListPage("내 각", s.picks, bgMint, medals = false, now)
+ Page.EVENTS -> EventsPage(s.events, now)
Page.SUNSET -> SunsetPage(s.sunset!!, now)
Page.HOURS -> HoursPage(s, now)
}
diff --git a/watch/app/src/main/java/kr/o2o/nalssigak/Screens.kt b/watch/app/src/main/java/kr/o2o/nalssigak/Screens.kt
index ed3bb2a..b00cb24 100644
--- a/watch/app/src/main/java/kr/o2o/nalssigak/Screens.kt
+++ b/watch/app/src/main/java/kr/o2o/nalssigak/Screens.kt
@@ -335,6 +335,30 @@ private fun GakRow(g: Gak, medal: String?, open: Boolean, modifier: Modifier, on
}
}
+@Composable
+fun EventsPage(events: List, now: Instant) {
+ Box(Modifier.fillMaxSize().background(bgButter)) {
+ Clock(now, Tok.ink)
+ Column(
+ Modifier.fillMaxSize().padding(start = 22.dp, end = 22.dp, top = 34.dp),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.spacedBy(6.dp),
+ ) {
+ T("근처 축제", 14.sp, color = Tok.ink)
+ events.forEach { e ->
+ Column(Modifier.fillMaxWidth().mallang().padding(start = 10.dp, end = 10.dp, top = 5.dp, bottom = 8.dp)) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ T(e.name, 13.sp, color = Tok.ink, modifier = Modifier.weight(1f), align = TextAlign.Start, maxLines = 1)
+ T(e.status, 9.sp, FontFamily.Default, Color.White, Modifier.padding(start = 4.dp).background(Tok.orange, CircleShape).padding(horizontal = 5.dp),
+ weight = FontWeight.ExtraBold, maxLines = 1)
+ }
+ T(listOfNotNull(e.place.takeIf { it.isNotBlank() }, e.fit).joinToString(" · "), 9.sp, FontFamily.Default, Tok.ink2, align = TextAlign.Start, weight = FontWeight.Bold, maxLines = 1)
+ }
+ }
+ }
+ }
+}
+
// ───────────── 4. 노을 ─────────────
// 웹 .b-skyline::after 의 건물 윤곽 (x%, y%)
diff --git a/watch/app/src/main/java/kr/o2o/nalssigak/Summary.kt b/watch/app/src/main/java/kr/o2o/nalssigak/Summary.kt
index 1b61961..45ed7be 100644
--- a/watch/app/src/main/java/kr/o2o/nalssigak/Summary.kt
+++ b/watch/app/src/main/java/kr/o2o/nalssigak/Summary.kt
@@ -22,6 +22,8 @@ data class Gak(val code: String, val name: String, val icon: String, val score:
data class Sunset(val isToday: Boolean, val score: Int, val grade: String, val sunsetAt: Instant, val bestAt: Instant)
data class Slot(val at: Instant, val icon: String, val tempC: Double?, val rainProb: Int?)
data class Phase(val startAt: Instant, val kind: String)
+/** 근처 축제·행사. status 는 "진행 중", "이번 토요일", "D-12" */
+data class Event(val name: String, val place: String, val status: String, val fit: String?)
data class Summary(
val regionName: String,
@@ -39,6 +41,7 @@ data class Summary(
val sunset: Sunset?,
val slots: List,
val timeline: List,
+ val events: List,
) {
/** 컴플리케이션·타일에 올릴 각: 내 각 첫 번째, 없으면 오늘 1위 */
val myGak: Gak? get() = picks.firstOrNull() ?: top.firstOrNull()
@@ -95,6 +98,7 @@ fun parseSummary(json: String): Summary {
},
slots = o.list("slots") { Slot(time(it.getString("at")), it.getString("icon"), it.dbl("temp_c"), it.int("rain_prob")) },
timeline = o.list("timeline") { Phase(time(it.getString("start_at")), it.getString("kind")) },
+ events = o.list("events") { Event(it.getString("name"), it.getString("place_name"), it.getString("status_label"), it.str("fit")) },
)
}
@@ -134,7 +138,7 @@ object SummaryRepo {
private fun refreshSurfaces(context: Context) {
val sources = listOf(GakComplicationService::class.java, RainComplicationService::class.java, Rank1ComplicationService::class.java,
Rank2ComplicationService::class.java, Rank3ComplicationService::class.java, Rank4ComplicationService::class.java,
- Rank5ComplicationService::class.java, Rank6ComplicationService::class.java, Rank7ComplicationService::class.java)
+ Rank5ComplicationService::class.java, Rank6ComplicationService::class.java, Rank7ComplicationService::class.java, EventComplicationService::class.java)
sources.forEach { ComplicationDataSourceUpdateRequester.create(context, ComponentName(context, it)).requestUpdateAll() }
TileService.getUpdater(context).requestUpdate(GakTileService::class.java)
}
diff --git a/watch/watchface/gen_watchface.py b/watch/watchface/gen_watchface.py
index 4ca9f18..c7f6bb9 100644
--- a/watch/watchface/gen_watchface.py
+++ b/watch/watchface/gen_watchface.py
@@ -3,9 +3,11 @@ HERE = os.path.dirname(os.path.abspath(__file__))
# 각 이름 → 아이콘. 시계 런타임이 점수 링 안의 작은 이미지를 그려 주지 않아, 이름을 보고 스킨에 넣은 아이콘을 고른다
GAK_ICONS = [(d["name"], d["icon"]) for d in json.load(open(os.path.join(HERE, "../../backend/seed/index_definition.json"), encoding="utf-8"))]
W = 450
-CX, CY = 225, 235
-ORB = 162
-RING, RR = 68, 148
+# 해 구슬을 줄이고 조금 내려, 날짜 밑에 축제 줄 자리를 만든다
+CX, CY = 225, 252
+ORB = 136
+RING, RR = 68, 138
+CHIP_Y = 366
ANGLES = [210, 330, 150, 30, 180, 0]
APP = "kr.o2o.nalssigak"
INK, ORANGE, SHADE, CARD = "#FF28304A", "#FFFF7A45", "#FFD9E5F4", "#B8FFFFFF"
@@ -90,7 +92,7 @@ def text(x, y, w, h, family, size, color, expr, amb=False):
def orb_slot():
x, y = CX - ORB // 2, CY - ORB // 2
- body = text(0, 30, ORB, 74, "bagel_fat_one", 58, "#FFFFFFFF", "[COMPLICATION.TEXT]") + text(14, 100, ORB - 28, 30, "jua", 21, "#FFFFFFFF", "[COMPLICATION.TITLE]")
+ body = text(0, int(ORB * .19), ORB, int(ORB * .45), "bagel_fat_one", 50, "#FFFFFFFF", "[COMPLICATION.TEXT]") + text(14, int(ORB * .62), ORB - 28, 28, "jua", 19, "#FFFFFFFF", "[COMPLICATION.TITLE]")
return f'''
@@ -145,12 +147,12 @@ def ring_slot(i, angle):
WEEKDAY = " : ".join(f'[DAY_OF_WEEK] == {n + 1} ? "{d}"' for n, d in enumerate("일월화수목금")) + " : "토""
def chip(x, w, icon, expr):
- return f'''{AMB0}
+ return f'''{AMB0}
- {AMB0}
- {text(x + 32, 369, w - 38, 30, "jua", 21, INK, expr, amb=True)}'''
+ {AMB0}
+ {text(x + 32, CHIP_Y + 5, w - 38, 30, "jua", 21, INK, expr, amb=True)}'''
def precip_slot():
"""화면 전체를 덮는 숨은 칸. 날씨각 앱(RainComplicationService)이 글자 = 기온, 제목 = 비 소식을 주면
@@ -201,6 +203,24 @@ def precip_slot():
'''
+def event_slot():
+ """날짜 밑 축제 한 줄. 날씨각 앱(EventComplicationService)이 글자 = 이름, 제목 = 상태를 준다. 행사가 없으면 빈 칸이라 안 그린다.
+ 무엇인지 바로 알게 "주변 축제" 를 앞에 두고 긴 이름만 말줄임"""
+ x, y, w, h = 123, 124, 204, 30
+ return f'''
+
+
+
+ {AMB0}
+
+
+ {AMB0}
+
+
+
+
+ '''
+
def date_line(ink):
return f'''{AMB0}
@@ -210,7 +230,7 @@ exprs = "\n ".join(f'\n {mode_block(v[1], v[2], v[3])}\n ' for k, v in MODES.items())
xml = f'''
-
@@ -237,6 +257,7 @@ xml = f'''
{clock("#FFFFFFFF", ambient_visible=True)}
{orb_slot()}
{"".join(ring_slot(i, a) for i, a in enumerate(ANGLES))}
+ {event_slot()}
'''
diff --git a/watch/watchface/src/main/res/raw/watchface.xml b/watch/watchface/src/main/res/raw/watchface.xml
index 45ac98b..acc11d3 100644
--- a/watch/watchface/src/main/res/raw/watchface.xml
+++ b/watch/watchface/src/main/res/raw/watchface.xml
@@ -1,5 +1,5 @@
-
@@ -371,20 +371,20 @@
-
+
-
-
+
+
-
+
-
-
+
+
@@ -393,18 +393,18 @@
= 21]]>
-
-
-
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
@@ -412,26 +412,26 @@
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
+
@@ -458,7 +458,7 @@
-
+
@@ -485,7 +485,7 @@
-
+
@@ -512,7 +512,7 @@
-
+
@@ -539,7 +539,7 @@
-
+
@@ -566,7 +566,7 @@
-
+
@@ -594,5 +594,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+