feat: 작업 중이던 변경 반영 — 글 주제(동네 이야기·하늘·비·단풍·옷차림)와 주제별 묶음을 피드 사이사이에, 이야기 페이지(/talk), 애드센스 코드·ads.txt·개인정보처리방침, 사진 검증을 Blob 주소까지
This commit is contained in:
1 parent
1393fc465c
commit
3cb58b9f0f
22 files changed
+718
-60
No files matched your search
@@ -401,6 +401,7 @@ class Talk(Base):
|
||||
body: Mapped[str] = mapped_column(String(100))
|
||||
weather: Mapped[Optional[str]] = mapped_column(String(30), nullable=True)
|
||||
image: Mapped[Optional[str]] = mapped_column(String(200), nullable=True)
|
||||
topic: Mapped[int] = mapped_column(SmallInteger, default=1)
|
||||
like_count: Mapped[int] = mapped_column(Integer, default=0)
|
||||
report_count: Mapped[int] = mapped_column(Integer, default=0)
|
||||
hidden: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
|
||||
@@ -115,6 +115,16 @@ class IndexCategory(CodeEnum):
|
||||
LIFE = 4
|
||||
|
||||
|
||||
class TalkTopic(CodeEnum):
|
||||
"""사람 글 주제. 안 고르면 동네 이야기. 피드에서 같은 주제 포스트 옆에 묶어 보여 준다"""
|
||||
|
||||
LOCAL = 1 # 동네 이야기
|
||||
SKY = 2 # 하늘·노을
|
||||
RAIN = 3 # 비·눈
|
||||
FOLIAGE = 4 # 단풍·꽃
|
||||
OUTFIT = 5 # 오늘 옷차림
|
||||
|
||||
|
||||
class TalkReport(CodeEnum):
|
||||
ABUSE = 1 # 욕설·비하
|
||||
SPAM = 2 # 광고·도배
|
||||
|
||||
@@ -13,7 +13,8 @@ from crud.reaction_crud import toggle_like_row
|
||||
|
||||
class TalkCRUD:
|
||||
async def page(
|
||||
self, s: AsyncSession, viewer: Optional[uuid.UUID], sido: Optional[str], boost_sec: int, cursor: Optional[tuple[int, int]], limit: int
|
||||
self, s: AsyncSession, viewer: Optional[uuid.UUID], sido: Optional[str], boost_sec: int, cursor: Optional[tuple[int, int]], limit: int,
|
||||
topic: Optional[int] = None,
|
||||
) -> list[tuple[Talk, User, Optional[str], int]]:
|
||||
"""최신 글부터. 보는 사람과 같은 시도 글은 boost_sec 만큼 늦게 쓴 것처럼 앞에 둔다. 숨김·지운 글과 내가 안 보기로 한 사람의 글은 뺀다.
|
||||
cursor 는 앞 페이지 마지막 글의 (정렬 키, talk_id)."""
|
||||
@@ -28,10 +29,24 @@ class TalkCRUD:
|
||||
)
|
||||
if viewer is not None:
|
||||
stmt = stmt.where(Talk.user_id.not_in(select(UserBlock.blocked_id).where(UserBlock.user_id == viewer)))
|
||||
if topic is not None:
|
||||
stmt = stmt.where(Talk.topic == topic)
|
||||
if cursor is not None:
|
||||
stmt = stmt.where(tuple_(key, Talk.talk_id) < tuple_(*cursor))
|
||||
return list((await s.execute(stmt.order_by(key.desc(), Talk.talk_id.desc()).limit(limit))).all())
|
||||
|
||||
async def recent(self, s: AsyncSession, viewer: Optional[uuid.UUID], since: datetime, limit: int) -> list[tuple[Talk, User, Optional[str]]]:
|
||||
"""since 뒤에 쓴 글 최신순 (숨김·지운 글, 내가 안 보기로 한 사람 글 빼고). 피드 묶음을 고를 재료"""
|
||||
stmt = (
|
||||
select(Talk, User, Region.short_name)
|
||||
.join(User, User.user_id == Talk.user_id)
|
||||
.outerjoin(Region, Region.code == Talk.region_code)
|
||||
.where(Talk.deleted.is_(False), Talk.hidden.is_(False), User.deleted.is_(False), Talk.created_at >= since)
|
||||
)
|
||||
if viewer is not None:
|
||||
stmt = stmt.where(Talk.user_id.not_in(select(UserBlock.blocked_id).where(UserBlock.user_id == viewer)))
|
||||
return list((await s.execute(stmt.order_by(Talk.created_at.desc()).limit(limit))).all())
|
||||
|
||||
async def mine(self, s: AsyncSession, user_id: uuid.UUID, cursor: Optional[int], limit: int) -> list[tuple[Talk, Optional[str]]]:
|
||||
"""내가 쓴 글, 최신부터. 신고로 숨겨진 글도 쓴 사람에겐 보인다."""
|
||||
stmt = select(Talk, Region.short_name).outerjoin(Region, Region.code == Talk.region_code).where(Talk.user_id == user_id, Talk.deleted.is_(False))
|
||||
@@ -48,8 +63,10 @@ class TalkCRUD:
|
||||
async def count_since(self, s: AsyncSession, user_id: uuid.UUID, since: datetime) -> int:
|
||||
return await s.scalar(select(func.count()).select_from(Talk).where(Talk.user_id == user_id, Talk.created_at >= since))
|
||||
|
||||
async def add(self, s: AsyncSession, user_id: uuid.UUID, region_code: str, body: str, weather: Optional[str], image: Optional[str] = None) -> Talk:
|
||||
t = Talk(user_id=user_id, region_code=region_code, body=body, weather=weather, image=image)
|
||||
async def add(
|
||||
self, s: AsyncSession, user_id: uuid.UUID, region_code: str, body: str, weather: Optional[str], image: Optional[str] = None, topic: int = 1
|
||||
) -> Talk:
|
||||
t = Talk(user_id=user_id, region_code=region_code, body=body, weather=weather, image=image, topic=topic)
|
||||
s.add(t)
|
||||
await s.flush()
|
||||
await s.refresh(t)
|
||||
|
||||
@@ -294,6 +294,9 @@ CREATE TABLE IF NOT EXISTS public.talk (
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_talk_list ON public.talk (talk_id DESC) WHERE deleted = FALSE AND hidden = FALSE;
|
||||
CREATE INDEX IF NOT EXISTS idx_talk_user_day ON public.talk (user_id, created_at);
|
||||
-- 글 주제 (TalkTopic: 1 동네 이야기, 2 하늘·노을, 3 비·눈, 4 단풍·꽃, 5 오늘 옷차림)
|
||||
ALTER TABLE public.talk ADD COLUMN IF NOT EXISTS topic SMALLINT NOT NULL DEFAULT 1;
|
||||
CREATE INDEX IF NOT EXISTS idx_talk_recent ON public.talk (created_at DESC) WHERE deleted = FALSE AND hidden = FALSE;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.talk_like (
|
||||
talk_id BIGINT NOT NULL,
|
||||
|
||||
@@ -3,7 +3,7 @@ from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from common.enums import TalkReport
|
||||
from common.enums import TalkReport, TalkTopic
|
||||
from common.models.gmodel import Req_WebPacketProtocol, Res_WebPacketProtocol, WebPacketProtocol
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ class TalkData(WebPacketProtocol):
|
||||
weather: Optional[str] = Field(None, description="쓸 때 그 동네 날씨 (18° 맑음)")
|
||||
body: str
|
||||
image: Optional[str] = Field(None, description="올린 사진 주소")
|
||||
topic: TalkTopic = TalkTopic.LOCAL
|
||||
like_count: int
|
||||
liked: bool
|
||||
mine: bool
|
||||
@@ -27,6 +28,7 @@ class Req_Talk(Req_WebPacketProtocol):
|
||||
region_code: str = Field(min_length=10, max_length=10)
|
||||
body: str = Field(min_length=1, max_length=200, description="공백을 줄인 뒤 100자까지")
|
||||
image: Optional[str] = Field(None, max_length=200, description="먼저 올린 사진 주소 (POST /v1/talk/image 결과)")
|
||||
topic: TalkTopic = Field(TalkTopic.LOCAL, description="글 주제. 안 고르면 동네 이야기")
|
||||
|
||||
|
||||
class Req_TalkReport(Req_WebPacketProtocol):
|
||||
@@ -38,6 +40,15 @@ class Res_TalkList(Res_WebPacketProtocol):
|
||||
next_cursor: Optional[str] = Field(None, description="다음 페이지를 받을 때 그대로 cursor 로 보낸다")
|
||||
|
||||
|
||||
class TalkGroup(WebPacketProtocol):
|
||||
topic: int = Field(description="0 이면 '동네 사람들'(모든 주제), 아니면 TalkTopic")
|
||||
talks: list[TalkData] = []
|
||||
|
||||
|
||||
class Res_TalkGroups(Res_WebPacketProtocol):
|
||||
groups: list[TalkGroup] = Field([], description="동네 사람들 묶음은 늘 있고(비어 있을 수 있음), 주제 묶음은 3장 이상일 때만")
|
||||
|
||||
|
||||
class Res_Talk(Res_WebPacketProtocol):
|
||||
talk: Optional[TalkData] = None
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ from fastapi.responses import FileResponse
|
||||
|
||||
from common.auth import current_user, optional_user
|
||||
from common.database.model.models import User
|
||||
from common.enums import ErrorType
|
||||
from common.enums import ErrorType, TalkTopic
|
||||
from common.liker import Liker, liker
|
||||
from common.models.errors import error_info
|
||||
from common.models.gmodel import Res_WebPacketProtocol
|
||||
from common.utils.kma_time import KST
|
||||
from router.v1.talk.protocol import Req_Talk, Req_TalkReport, Res_Talk, Res_TalkImage, Res_TalkLike, Res_TalkList, TalkData
|
||||
from router.v1.talk.protocol import Req_Talk, Req_TalkReport, Res_Talk, Res_TalkGroups, Res_TalkImage, Res_TalkLike, Res_TalkList, TalkData, TalkGroup
|
||||
from services.talk_image import MAX_BYTES, URL_PREFIX, file_of, save
|
||||
from services.talk_service import TalkService, TalkView
|
||||
|
||||
@@ -23,19 +23,33 @@ def _data(v: TalkView) -> TalkData:
|
||||
t, u = v.talk, v.author
|
||||
return TalkData(
|
||||
talk_id=t.talk_id, nickname=u.nickname, character=u.character, color=u.color, mood=u.mood, region_name=v.region_name, weather=t.weather,
|
||||
body=t.body, image=t.image, like_count=t.like_count, liked=v.liked, mine=v.mine, created_at=t.created_at.astimezone(KST),
|
||||
body=t.body, image=t.image, topic=TalkTopic(t.topic), like_count=t.like_count, liked=v.liked, mine=v.mine, created_at=t.created_at.astimezone(KST),
|
||||
)
|
||||
|
||||
|
||||
@router.get("/groups", response_model=Res_TalkGroups, response_model_exclude_none=True, summary="오늘 피드 묶음 (동네 사람들 + 주제별, 가까운 동네·덜 지난 글 먼저, 한 사람 한 장)")
|
||||
async def talk_groups(
|
||||
region: Optional[str] = Query(None, min_length=10, max_length=10, description="보는 사람의 구 행정코드"),
|
||||
user: Optional[User] = Depends(optional_user),
|
||||
who: Liker = Depends(liker),
|
||||
service: TalkService = Depends(),
|
||||
) -> Res_TalkGroups:
|
||||
err, groups = await service.groups(user, who.ip_hash, region)
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return Res_TalkGroups(result=error_info(err))
|
||||
return Res_TalkGroups(groups=[TalkGroup(topic=k, talks=[_data(v) for v in vs]) for k, vs in groups.items()])
|
||||
|
||||
|
||||
@router.get("/list", response_model=Res_TalkList, response_model_exclude_none=True, summary="동네 이야기 (전국 최신순, 보는 동네와 같은 시도 글은 앞으로, 같은 사람 글은 띄움, 로그인 없이 보기)")
|
||||
async def list_talks(
|
||||
region: Optional[str] = Query(None, min_length=10, max_length=10, description="보는 사람의 구 행정코드"),
|
||||
topic: Optional[TalkTopic] = Query(None, description="이 주제 글만. 없으면 전체"),
|
||||
cursor: Optional[str] = Query(None, max_length=40),
|
||||
user: Optional[User] = Depends(optional_user),
|
||||
who: Liker = Depends(liker),
|
||||
service: TalkService = Depends(),
|
||||
) -> Res_TalkList:
|
||||
err, views, nxt = await service.page(user, who.ip_hash, region, cursor)
|
||||
err, views, nxt = await service.page(user, who.ip_hash, region, cursor, topic.value if topic else None)
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return Res_TalkList(result=error_info(err))
|
||||
return Res_TalkList(talks=[_data(v) for v in views], next_cursor=nxt)
|
||||
@@ -53,7 +67,7 @@ async def list_my_talks(cursor: Optional[str] = Query(None, max_length=20), user
|
||||
|
||||
@router.post("", response_model=Res_Talk, response_model_exclude_none=True, summary="동네 이야기 쓰기 (링크·전화번호 불가, 하루 5개)")
|
||||
async def add_talk(req: Req_Talk, user: User = Depends(current_user), service: TalkService = Depends()) -> Res_Talk:
|
||||
err, v = await service.add(user, req.region_code, req.body, req.image)
|
||||
err, v = await service.add(user, req.region_code, req.body, req.image, req.topic)
|
||||
return Res_Talk(result=error_info(err)) if err is not ErrorType.SUCCESS or v is None else Res_Talk(talk=_data(v))
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import math
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from datetime import timedelta
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import Depends
|
||||
|
||||
from common.database.db_session_manager import DB_SESSION_MNG
|
||||
from common.database.model.models import Talk, User, WeatherHourly
|
||||
from common.enums import ErrorType, RainType, Sky, TalkReport
|
||||
from common.enums import ErrorType, RainType, Sky, TalkReport, TalkTopic
|
||||
from common.liker import Liker
|
||||
from common.utils.kma_time import kst_midnight, now_kst
|
||||
from crud.region_crud import RegionCRUD
|
||||
from crud.talk_crud import TalkCRUD
|
||||
from crud.weather_crud import WeatherCRUD
|
||||
from services.talk_image import file_of
|
||||
from services.talk_image import is_ours
|
||||
|
||||
BODY_MAX = 100
|
||||
DAILY_MAX = 5
|
||||
@@ -22,6 +23,13 @@ HIDE_AT = 3
|
||||
PAGE = 20
|
||||
# 보는 사람과 같은 시도에서 쓴 글은 이만큼 늦게 쓴 글처럼 앞에 둔다
|
||||
LOCAL_BOOST = timedelta(hours=12)
|
||||
# 피드 묶음: 최근 이 기간 글 중에서 고른다. 한 묶음 최대 장수, 이보다 적으면 주제 묶음은 숨긴다
|
||||
GROUP_WINDOW = timedelta(days=7)
|
||||
GROUP_POOL = 300
|
||||
GROUP_MAX = 10
|
||||
GROUP_MIN = 3
|
||||
# 묶음 순서는 '덜 지난 것처럼 쳐 주는 시간'으로 매긴다: 같은 구 6시간, 같은 시도 3시간, 좋아요는 2시간 × log2(1+좋아요)
|
||||
NEAR_GU_H, NEAR_SIDO_H, LIKE_H = 6, 3, 2
|
||||
|
||||
# 링크(http, www, 도메인 꼴)와 전화번호(010-1234-5678, 01012345678, 02-123-4567)
|
||||
_LINK = re.compile(r"https?://|www\.|[a-z0-9-]+\.(?:com|net|kr|co|org|io|me|ly|gl)\b", re.I)
|
||||
@@ -51,6 +59,30 @@ def spread_authors(views: list["TalkView"]) -> list["TalkView"]:
|
||||
return out
|
||||
|
||||
|
||||
def group_age(t: Talk, region_code: Optional[str], now: datetime) -> float:
|
||||
"""묶음 안 정렬 값(작을수록 앞): 지난 시간에서 가까운 동네·좋아요만큼 뺀다. 오래된 글은 좋아요가 많아도 결국 뒤로 간다"""
|
||||
age = (now - t.created_at).total_seconds() / 3600
|
||||
near = NEAR_GU_H if region_code and t.region_code == region_code else NEAR_SIDO_H if region_code and t.region_code[:2] == region_code[:2] else 0
|
||||
return age - near - LIKE_H * math.log2(1 + t.like_count)
|
||||
|
||||
|
||||
def pick_group(views: list["TalkView"], region_code: Optional[str], now: datetime) -> list["TalkView"]:
|
||||
"""한 사람 한 장, 최대 GROUP_MAX 장. 첫 장은 신고 받은 적 없는 글"""
|
||||
out: list[TalkView] = []
|
||||
seen: set = set()
|
||||
for v in sorted(views, key=lambda v: group_age(v.talk, region_code, now)):
|
||||
if v.author.user_id in seen:
|
||||
continue
|
||||
seen.add(v.author.user_id)
|
||||
out.append(v)
|
||||
if len(out) == GROUP_MAX:
|
||||
break
|
||||
clean = next((i for i, v in enumerate(out) if v.talk.report_count == 0), None)
|
||||
if clean:
|
||||
out.insert(0, out.pop(clean))
|
||||
return out
|
||||
|
||||
|
||||
def parse_cursor(cursor: str) -> Optional[tuple[int, int]]:
|
||||
key, _, talk_id = cursor.partition("_")
|
||||
return (int(key), int(talk_id)) if key.lstrip("-").isdigit() and talk_id.isdigit() else None
|
||||
@@ -69,14 +101,36 @@ class TalkService:
|
||||
def __init__(self, crud: TalkCRUD = Depends(TalkCRUD), regions: RegionCRUD = Depends(RegionCRUD), weather: WeatherCRUD = Depends(WeatherCRUD)) -> None:
|
||||
self.crud, self.regions, self.weather = crud, regions, weather
|
||||
|
||||
async def page(self, user: Optional[User], ip_hash: str, region_code: Optional[str], cursor: Optional[str]) -> tuple[ErrorType, list[TalkView], Optional[str]]:
|
||||
async def groups(self, user: Optional[User], ip_hash: str, region_code: Optional[str]) -> tuple[ErrorType, dict[int, list[TalkView]]]:
|
||||
"""피드 묶음. 0은 '동네 사람들'(모든 주제), 나머지는 주제별(GROUP_MIN 장 이상일 때만)"""
|
||||
now = now_kst()
|
||||
viewer = user.user_id if user else None
|
||||
err, rows = await DB_SESSION_MNG.execute_lambda(lambda s: self.crud.recent(s, viewer, now - GROUP_WINDOW, GROUP_POOL))
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return err, {}
|
||||
err, liked = await self._liked(user, ip_hash, [t.talk_id for t, *_ in rows])
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return err, {}
|
||||
views = [TalkView(talk=t, author=u, region_name=name, liked=t.talk_id in liked, mine=viewer == t.user_id) for t, u, name in rows]
|
||||
out = {0: pick_group(views, region_code, now)}
|
||||
for topic in TalkTopic:
|
||||
if topic is TalkTopic.LOCAL:
|
||||
continue
|
||||
group = pick_group([v for v in views if v.talk.topic == topic.value], region_code, now)
|
||||
if len(group) >= GROUP_MIN:
|
||||
out[topic.value] = group
|
||||
return ErrorType.SUCCESS, out
|
||||
|
||||
async def page(
|
||||
self, user: Optional[User], ip_hash: str, region_code: Optional[str], cursor: Optional[str], topic: Optional[int] = None
|
||||
) -> tuple[ErrorType, list[TalkView], Optional[str]]:
|
||||
"""한 페이지와 다음 페이지 cursor. 같은 사람 글은 페이지 안에서 떨어뜨린다."""
|
||||
after = parse_cursor(cursor) if cursor else None
|
||||
if cursor and after is None:
|
||||
return ErrorType.INVALID_INPUT, [], None
|
||||
viewer = user.user_id if user else None
|
||||
sido = region_code[:2] if region_code else None
|
||||
err, rows = await DB_SESSION_MNG.execute_lambda(lambda s: self.crud.page(s, viewer, sido, int(LOCAL_BOOST.total_seconds()), after, PAGE))
|
||||
err, rows = await DB_SESSION_MNG.execute_lambda(lambda s: self.crud.page(s, viewer, sido, int(LOCAL_BOOST.total_seconds()), after, PAGE, topic))
|
||||
if err is not ErrorType.SUCCESS:
|
||||
return err, [], None
|
||||
err, liked = await self._liked(user, ip_hash, [t.talk_id for t, *_ in rows])
|
||||
@@ -111,11 +165,13 @@ class TalkService:
|
||||
return None
|
||||
return weather_line(min(rows, key=lambda r: abs(r.forecast_at - now)))
|
||||
|
||||
async def add(self, user: User, region_code: str, body: str, image: Optional[str] = None) -> tuple[ErrorType, Optional[TalkView]]:
|
||||
async def add(
|
||||
self, user: User, region_code: str, body: str, image: Optional[str] = None, topic: TalkTopic = TalkTopic.LOCAL
|
||||
) -> tuple[ErrorType, Optional[TalkView]]:
|
||||
body = " ".join(body.split())
|
||||
if not body or len(body) > BODY_MAX:
|
||||
return ErrorType.INVALID_INPUT, None
|
||||
if image is not None and file_of(image) is None:
|
||||
if image is not None and not is_ours(image):
|
||||
return ErrorType.INVALID_INPUT, None
|
||||
if _LINK.search(body) or _PHONE.search(body):
|
||||
return ErrorType.LINK_NOT_ALLOWED, None
|
||||
@@ -131,7 +187,7 @@ class TalkService:
|
||||
if n >= DAILY_MAX:
|
||||
return ErrorType.DAILY_LIMIT, None
|
||||
weather = await self._weather_now(region_code)
|
||||
err, t = await DB_SESSION_MNG.execute_lambda_write(lambda s: self.crud.add(s, user.user_id, region_code, body, weather, image))
|
||||
err, t = await DB_SESSION_MNG.execute_lambda_write(lambda s: self.crud.add(s, user.user_id, region_code, body, weather, image, topic.value))
|
||||
if err is not ErrorType.SUCCESS or t is None:
|
||||
return err, None
|
||||
return ErrorType.SUCCESS, TalkView(talk=t, author=user, region_name=region.short_name, liked=False, mine=True)
|
||||
|
||||
@@ -4,7 +4,9 @@ import pytest
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
|
||||
from router.router import app
|
||||
from services.talk_service import DAILY_MAX, HIDE_AT, parse_cursor, spread_authors, weather_line
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from services.talk_service import DAILY_MAX, GROUP_MAX, HIDE_AT, parse_cursor, pick_group, spread_authors, weather_line
|
||||
|
||||
REGION = "1144000000"
|
||||
BUSAN = "2611000000"
|
||||
@@ -143,3 +145,49 @@ def test_spread_authors_and_cursor():
|
||||
assert [x.author.user_id for x in spread_authors([v("a"), v("a"), v("a"), v("b"), v("c")])] == ["a", "b", "a", "c", "a"]
|
||||
assert parse_cursor("1760000000_42") == (1760000000, 42)
|
||||
assert parse_cursor("12") is None and parse_cursor("x_1") is None
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_topic_is_saved_and_filters_list():
|
||||
async with client() as c:
|
||||
h = await _login(c, "talk_tp1")
|
||||
sky = (await c.post("/v1/talk", json={"region_code": REGION, "body": "노을 분홍빛", "topic": 2}, headers=h)).json()["talk"]
|
||||
plain = (await _write(c, h, "그냥 동네 이야기"))["talk"]
|
||||
assert sky["topic"] == 2 and plain["topic"] == 1
|
||||
only_sky = _ids((await c.get("/v1/talk/list", params={"topic": 2})).json())
|
||||
only_foliage = _ids((await c.get("/v1/talk/list", params={"topic": 4})).json())
|
||||
assert sky["talk_id"] in only_sky and plain["talk_id"] not in only_sky
|
||||
assert sky["talk_id"] not in only_foliage
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_groups_have_near_group_and_topic_group_from_three_people():
|
||||
async with client() as c:
|
||||
for i in range(3):
|
||||
h = await _login(c, f"talk_gr{i}")
|
||||
for j in range(2):
|
||||
await c.post("/v1/talk", json={"region_code": REGION, "body": f"단풍 물들었어요 {i}-{j}", "topic": 4}, headers=h)
|
||||
groups = {g["topic"]: g["talks"] for g in (await c.get("/v1/talk/groups", params={"region": REGION})).json()["groups"]}
|
||||
assert 0 in groups and 4 in groups
|
||||
assert all(t["topic"] == 4 for t in groups[4])
|
||||
for talks in groups.values():
|
||||
names = [t["nickname"] for t in talks]
|
||||
assert len(names) == len(set(names)) and len(talks) <= GROUP_MAX
|
||||
|
||||
|
||||
def _view(talk_id, user, region, hours_ago, likes=0, reports=0):
|
||||
now = datetime(2026, 10, 23, 12, tzinfo=timezone.utc)
|
||||
talk = SimpleNamespace(talk_id=talk_id, region_code=region, created_at=now - timedelta(hours=hours_ago), like_count=likes, report_count=reports)
|
||||
return SimpleNamespace(talk=talk, author=SimpleNamespace(user_id=user))
|
||||
|
||||
|
||||
def test_pick_group_orders_near_fresh_first_one_per_person_clean_first():
|
||||
now = datetime(2026, 10, 23, 12, tzinfo=timezone.utc)
|
||||
far = _view(1, "a", BUSAN, 1)
|
||||
same_sido = _view(2, "b", "1111000000", 1)
|
||||
same_gu = _view(3, "c", REGION, 1)
|
||||
old_popular = _view(4, "d", REGION, 30, likes=50)
|
||||
again = _view(5, "c", REGION, 0)
|
||||
assert [v.talk.talk_id for v in pick_group([far, same_sido, same_gu, old_popular, again], REGION, now)] == [5, 2, 1, 4]
|
||||
reported = _view(6, "e", REGION, 0, reports=1)
|
||||
assert pick_group([reported, far], REGION, now)[0].talk.talk_id == 1
|
||||
@@ -0,0 +1,87 @@
|
||||
# 검색 노출 기록
|
||||
|
||||
순위 = 결과에서 weather.o2o.kr이 몇 번째 사이트인지(같은 사이트는 한 번만 셈). `-` 첫 페이지에 없음. 적힌 검색어만 나온 것, 나머지는 `-`.
|
||||
구글은 첫 페이지(사이트 6~9개)만 본다. 로그인한 브라우저·위치(성남) 기준.
|
||||
|
||||
## 검색어 묶음
|
||||
|
||||
- 기본: 날씨각 · 오늘 날씨 · 분당구 오늘 날씨 · 분당 날씨 · 성남 오늘 날씨 · 마포구 오늘 날씨 · 마포구 날씨 · 강남구 오늘 날씨 · 세차하기 좋은 날 · 빨래하기 좋은 날 · 오늘 노을 시간 · 이번 주말 날씨 · 세차각
|
||||
- 지역(10/20~): 아래 29곳 × `{지역} 날씨` · `{지역} 오늘 날씨` · `오늘 {지역} 날씨`
|
||||
분당구 성남 수원 부평구 연수구 강남구 구로구 마포구 성동구 송파구 / 서울 중구 광주 남구 이천 완도 동해 시흥 김해 춘천 수성구 화성 군산 제주 / 청주 상당구 용인 처인구 전주 완산구 포항 남구 해운대구 노원구 관악구
|
||||
- 일반(10/20~): 날씨 각 · 날씨각 성남 · 오늘 일몰 시간 · 노을 시간 · 세차 날씨 · 빨래 날씨 · 등산 날씨 · 캠핑 날씨 · 산책하기 좋은 날씨 · 오늘 우산 필요 · 미세먼지 오늘
|
||||
|
||||
## 기록
|
||||
|
||||
| 날짜 | 엔진 | 범위 | 나온 검색어 (순위 · 주소) | 색인 수 | 비고 |
|
||||
|---|---|---|---|---|---|
|
||||
| 10/19 | 구글 | 기본 | 날씨각 3 | 약 10 | 사이트 이름 '에이아이오투오' |
|
||||
| 10/19 | 네이버 | 기본 | 날씨각 1, 마포구 오늘 날씨 9 | 10 | |
|
||||
| 10/20 | 구글 | 기본 | 날씨각 3 | | 사이트 이름 '에이아이오투오' |
|
||||
| 10/20 | 네이버 | 기본 | 날씨각 1, 마포구 오늘 날씨 약 11, 강남구 오늘 날씨 약 6 | 10 | 분당·성남 3개 차단 |
|
||||
| 10/20 밤 | 구글 | 기본+분당구·성남 날씨 | 날씨각 2 | 51 (`/today` 47, 구 주소 5) | 구 주소 색인: 분당·청주 상당·용인 처인·전주 완산·포항 남 |
|
||||
| 10/20 밤 | 네이버 | 지역+일반 98개 | 날씨각 성남 1 `/today/gyeonggi/seongnam`, 부평구 오늘 6, 연수구 오늘 6, 강남구 오늘 6, 구로구 오늘 7, 성동구 오늘 7, 송파구 오늘 8, 마포구 오늘 12 | 10 | 색인: 홈·성남·수원·부평·연수·강남·구로·마포·성동·송파 |
|
||||
| 10/21 | 구글 | 기본 2개 + 지역 11곳(분당구~서울 중구) | 날씨각 4 | | 37번째부터 막힘, 나머지 66개 못 봄 |
|
||||
| 10/21 | 구글 | 구 39개 `오늘 {구} 날씨` (1~2페이지) | 구 주소로 25개: 장안·권선·팔달·영통·수정·만안·동안·원미·소사·덕양·일산동·일산서·수지·효행(1페이지)·병점·동탄·상당·서원·흥덕·청원·천안서북·의창·성산·완산·덕진. 시 주소로 2개: 중원→`/seongnam`, 만세→`/hwaseong` | 구 39개 모두 색인 | 없음 12개: 분당(2p에 보였다 안 보였다)·오정·상록·단원·처인·기흥·천안동남·포항남·포항북·마산합포·마산회원·진해 |
|
||||
| 10/21 | 네이버 | 구 39개 `오늘 {구} 날씨` | 0개 | 구 주소 색인 0 | |
|
||||
| 10/21 | 네이버 | 지역+일반 98개 | 날씨각 성남 1, 강남구 오늘 4, 연수구 오늘 5, 구로구 오늘 6, 날씨 각 6 `/`, 송파구 오늘 8, 마포구 오늘 10, 부평구 오늘 14 | | 성동구 오늘 빠짐 |
|
||||
| 10/23 | 구글 | 10/21 없던 구 12개 `오늘 {구} 날씨`(1~2p) + 분당 + 내일 5개 + 날씨각 | 2p로 들어옴 7개: 오정 4·상록 6·단원 4·기흥 8(`/tomorrow/` 주소)·천안동남 7·마산합포 5·분당 6. `내일 날씨 뭐 할까` **1p 4위** `/tomorrow/gyeonggi/seongnam`. 날씨각 2 | 약 347 (10/20 51) | 여전히 없음 5개: 처인·포항남·포항북·마산회원·진해. `분당구·성남·수원·강남구 내일 날씨` 1p 없음. 1p는 전부 0 |
|
||||
| 10/23 | 네이버 | 지역 29곳×4꼴(`내일` 추가) + 일반 13 + 구 39개 `오늘 {구} 날씨` (168개) | 날씨각 **1** (새로 나옴), 날씨각 성남 1, `{구} 오늘 날씨`: 부평 5·강남 5·성동 5·연수 6·구로 6·마포 6·송파 7, `오늘 {구} 날씨`(10/21엔 0): 성동 6·부평 7·강남 7·구로 10·마포 10·송파 10·연수 11 | 16 이상 (10/21 10) | 새 색인: 서울 종로·중구·용산, /sky·/week·/season. 경기 등 구 39개 여전히 0, `내일 날씨` 꼴 0 |
|
||||
|
||||
|
||||
## 구글 구 39개 표
|
||||
|
||||
`2p6` = 2페이지 6번째 사이트. `내일` = 내일 페이지(`/tomorrow/`)가 나옴, `시` = 구 대신 시 페이지. `-` = 2페이지 안에 없음, 빈칸 = 안 봄.
|
||||
|
||||
| 구 | 10/21 `오늘 {구} 날씨` | 10/23 `오늘 {구} 날씨` | 10/23 `{구} 오늘 날씨` |
|
||||
|---|---|---|---|
|
||||
| 수원 장안 | 2p | | 2p6 |
|
||||
| 수원 권선 | 2p | | 2p7 |
|
||||
| 수원 팔달 | 2p | | 2p6 내일 |
|
||||
| 수원 영통 | 2p | | 2p5 내일 |
|
||||
| 성남 수정 | 2p | | 2p7 시 |
|
||||
| 성남 중원 | 2p 시 | | 2p6 시 |
|
||||
| 성남 분당 | - | 2p6 | 2p4 |
|
||||
| 안양 만안 | 2p | | 2p5 |
|
||||
| 안양 동안 | 2p | | 2p6 내일 |
|
||||
| 부천 원미 | 2p | | 2p6 |
|
||||
| 부천 소사 | 2p | | 2p5 |
|
||||
| 부천 오정 | - | 2p4 | 2p2 내일 |
|
||||
| 안산 상록 | - | 2p6 | 2p6 |
|
||||
| 안산 단원 | - | 2p4 | - |
|
||||
| 고양 덕양 | 2p | | 2p6 |
|
||||
| 고양 일산동 | 2p | | 2p5 |
|
||||
| 고양 일산서 | 2p | | - |
|
||||
| 용인 처인 | - | - | 2p8 |
|
||||
| 용인 기흥 | - | 2p8 내일 | - |
|
||||
| 용인 수지 | 2p | | 2p7 |
|
||||
| 화성 만세 | 2p 시 | | 2p3 |
|
||||
| 화성 효행 | **1p** | | 2p1 내일 |
|
||||
| 화성 병점 | 2p | | 2p4 |
|
||||
| 화성 동탄 | 2p | | 2p7 내일 |
|
||||
| 청주 상당 | 2p | | |
|
||||
| 청주 서원 | 2p | | |
|
||||
| 청주 흥덕 | 2p | | |
|
||||
| 청주 청원 | 2p | | |
|
||||
| 천안 동남 | - | 2p7 | |
|
||||
| 천안 서북 | 2p | | |
|
||||
| 포항 남 | - | - | |
|
||||
| 포항 북 | - | - | |
|
||||
| 창원 의창 | 2p | | |
|
||||
| 창원 성산 | 2p | | |
|
||||
| 창원 마산합포 | - | 2p5 | |
|
||||
| 창원 마산회원 | - | - | |
|
||||
| 창원 진해 | - | - | |
|
||||
| 전주 완산 | 2p | | |
|
||||
| 전주 덕진 | 2p | | |
|
||||
## 메모
|
||||
|
||||
- 네이버는 `{구} 오늘 날씨` 꼴에서만 나온다. 같은 구라도 `{구} 날씨`·`오늘 {구} 날씨`는 안 나온다.
|
||||
- 네이버는 색인된 9곳 밖 지역이 나올 수 없다. 성남·수원은 색인돼 있어도 안 나온다.
|
||||
- 구글은 브라우저 fetch로 30여 개 치면 막힌다(결과 대신 확인 화면 → 보안문자). 하루 30개 안쪽으로 나눠 치거나 서치 콘솔 실적 보고서로 본다.
|
||||
- 10/21 구글 '오늘 분당구 날씨' **2페이지**에 `/today/gyeonggi/seongnam/bundang`(제목 '분당구 오늘 날씨, 뭐 할까? · 성남시') 나옴. 사용자 화면 2번째, 내 화면 9번째. 10/20 배포한 구 주소가 하루 만에 잡힘. 첫 페이지만 보는 테스트로는 놓친다 → 2페이지까지 본다.
|
||||
- 10/21 떨어진 것 확인: 우리 페이지(제목·설명·canonical)는 그대로, 네이버 색인 10개도 그대로(성동·부평 포함). 부평구 오늘 6→14는 위에 뉴스 4곳(newsinside·wikitree·YTN·KBS)이 새로 들어옴(비 오는 날). 성동구 오늘은 결과 사이트가 9곳뿐인 판에서 빠짐, 1~9위는 기상청·웨더아이·weather.com·accuweather 등. 구글 날씨각 2→4는 위 사이트를 저장 안 해서 원인 못 봄 → 다음부터 상위 사이트도 저장.
|
||||
- 10/21 같은 날 1시간 안에 다시 쳤더니 성동구 오늘 -→6, 부평구 오늘 14→9, 강남구 4→5, 송파 8→7. 네이버는 요청마다 뉴스 칸 등 구성이 바뀌어 ±5 안팎 변동은 잡음. 하루 비교로 오르내림 판단 금지, 3일 이상 같은 방향일 때만 원인 분석.
|
||||
- 10/21 서치 콘솔 URL 검사: 구 주소 39개 모두 "URL이 Google에 등록되어 있음" → 구글은 색인 문제가 아니라 순위 문제. 색인 생성 요청 안 함.
|
||||
- 상위 사이트 목록: `docs/search_log/날짜_naver_top.tsv` (10/21, 10/23) (검색어 → 1~15위 호스트). 다음 날 이 파일과 비교해 누가 새로 위에 들어왔는지 본다.
|
||||
- 10/20 구글 '분당구 오늘 날씨' 1~8위는 모두 제목에 '분당구'가 있는 구 단위 페이지.
|
||||
- 10/23 서치 콘솔 URL 검사: 내일 페이지 13곳(송파·남양주·평택·강서·강남·달서·김해·시흥·파주·광진·부산진·완도·진해) 모두 "URL이 Google에 등록되어 있음" → 구글은 사이트맵으로 내일 페이지를 이미 가져감, 색인 요청 안 함. 네이버 서치어드바이저는 Claude in Chrome에서 막혀 사람이 넣어야 함(순서: `docs/search_log/색인요청_인구순.txt`).
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
- 제외: 소상공인·업종별 기능, 사용자 지수 만들기, 제철 식재료·축제(나중), 알림·제보
|
||||
|
||||
- 웹 먼저, 로그인 없음, 광고 없음, 국내 전국
|
||||
- 웹 먼저, 로그인 없음, 피드 사이 인피드 광고(AdSense), 국내 전국
|
||||
- 화면: PC와 모바일을 각각 설계. PC는 여러 지수를 한눈에, 카드 넘기기는 PC에서도 일부 유지
|
||||
- 하루 날씨는 3시간 단위로 보여줌
|
||||
- 공유: 이미지 카드 + 링크
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
gtag('config', 'G-D378J4X373');
|
||||
</script>
|
||||
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4414665130371841" crossorigin="anonymous"></script>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
google.com, pub-4414665130371841, DIRECT, f08c47fec0942fa0
|
||||
@@ -36,7 +36,7 @@
|
||||
<p>회원 정보는 회원 탈퇴 시까지 보관하며, 탈퇴 요청을 받으면 지체 없이 파기합니다. 접속 기록은 「통신비밀보호법」에 따라 3개월간 보관합니다.</p>
|
||||
|
||||
<h2>3. 제3자 제공 및 처리 위탁</h2>
|
||||
<p>회사는 이용자의 개인정보를 제3자에게 제공하지 않습니다. 이용 통계 분석을 위해 Google Analytics(Google LLC)를 사용하며, 이 과정에서 쿠키와 기기 정보가 Google에 전송될 수 있습니다. 브라우저 설정에서 쿠키를 거부할 수 있습니다.</p>
|
||||
<p>회사는 이용자의 개인정보를 제3자에게 제공하지 않습니다. 이용 통계 분석을 위해 Google Analytics(Google LLC)를 사용하며, 이 과정에서 쿠키와 기기 정보가 Google에 전송될 수 있습니다. 광고 게재를 위해 Google AdSense(Google LLC)를 사용하며, Google은 쿠키로 이 사이트와 다른 사이트 방문 기록을 바탕으로 광고를 보여 줄 수 있습니다. 맞춤 광고는 Google 광고 설정(https://adssettings.google.com)에서 끌 수 있습니다. 브라우저 설정에서 쿠키를 거부할 수 있습니다.</p>
|
||||
|
||||
<h2>4. 파기 절차 및 방법</h2>
|
||||
<p>보유 기간이 끝나거나 목적이 달성된 개인정보는 지체 없이 복구할 수 없는 방법으로 삭제합니다.</p>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { FoliagePage } from './b/FoliagePage'
|
||||
import { GakPage } from './b/GakPage'
|
||||
import { SeasonPage } from './b/SeasonPage'
|
||||
import { SkyPage } from './b/SkyPage'
|
||||
import { TalkPage } from './b/TalkPage'
|
||||
import { TodayPage } from './b/TodayPage'
|
||||
import { WeekPage } from './b/WeekPage'
|
||||
|
||||
@@ -20,6 +21,7 @@ export default function App() {
|
||||
<Route path="week" element={<WeekPage />} />
|
||||
<Route path="season" element={<SeasonPage />} />
|
||||
<Route path="foliage" element={<FoliagePage />} />
|
||||
<Route path="talk" element={<TalkPage />} />
|
||||
<Route path="*" element={<TodayPage />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import { type DefaultError, type InfiniteData, infiniteQueryOptions, queryOptions, type UseMutationOptions } from '@tanstack/react-query';
|
||||
|
||||
import { client } from '../client.gen';
|
||||
import { addComment, addMyGak, addTalk, authConfig, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, googleLogin, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listMyTalks, listPlaces, listPresets, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, scoreMyGak, signup, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from '../sdk.gen';
|
||||
import type { AddCommentData, AddCommentError, AddCommentResponse, AddMyGakData, AddMyGakError, AddMyGakResponse, AddTalkData, AddTalkError, AddTalkResponse, AuthConfigData, AuthConfigResponse, BlockTalkAuthorData, BlockTalkAuthorError, BlockTalkAuthorResponse, DeleteCommentData, DeleteCommentError, DeleteCommentResponse, DeleteMyGakData, DeleteMyGakError, DeleteMyGakResponse, DeleteTalkData, DeleteTalkError, DeleteTalkResponse, GetArticleData, GetArticleError, GetArticleResponse, GetFeedData, GetFeedError, GetFeedResponse, GetImageData, GetImageError, GetIndexData, GetIndexError, GetIndexResponse, GetPostData, GetPostError, GetPostResponse, GetSeasonWeekData, GetSeasonWeekResponse, GetSkyData, GetSkyError, GetSkyRankingData, GetSkyRankingResponse, GetSkyResponse, GetTalkImageData, GetTalkImageError, GetTodayGuPageData, GetTodayGuPageError, GetTodayGuPageResponse, GetTodayPageData, GetTodayPageError, GetTodayPageResponse, GetWatchSummaryData, GetWatchSummaryError, GetWatchSummaryResponse, GetWeatherNowData, GetWeatherNowError, GetWeatherNowResponse, GetWeatherTodayData, GetWeatherTodayError, GetWeatherTodayResponse, GetWeekData, GetWeekError, GetWeekRankingData, GetWeekRankingResponse, GetWeekResponse, GoogleLoginData, GoogleLoginError, GoogleLoginResponse, HealthzHealthzGetData, HealthzHealthzGetResponse, LikeCommentData, LikeCommentError, LikeCommentResponse, LikePostData, LikePostError, LikePostResponse, LikeTalkData, LikeTalkError, LikeTalkResponse, ListArticlesData, ListArticlesError, ListArticlesResponse, ListCommentsData, ListCommentsError, ListCommentsResponse, ListEventsData, ListEventsError, ListEventsResponse, ListIndicesData, ListIndicesError, ListIndicesResponse, ListMyGakData, ListMyGakError, ListMyGakResponse, ListMyTalksData, ListMyTalksError, ListMyTalksResponse, ListPlacesData, ListPlacesError, ListPlacesResponse, ListPresetsData, ListPresetsResponse, ListRegionsData, ListRegionsError, ListRegionsResponse, ListSavedData, ListSavedError, ListSavedResponse, ListTalksData, ListTalksError, ListTalksResponse, LoginData, LoginError, LoginResponse, LogoutData, LogoutError, LogoutResponse, MeData, MeError, MeResponse, NearestRegionData, NearestRegionError, NearestRegionResponse, RefreshData, RefreshError, RefreshResponse, ReportTalkData, ReportTalkError, ReportTalkResponse, SavePostData, SavePostError, SavePostResponse, ScoreMyGakData, ScoreMyGakError, ScoreMyGakResponse, SignupData, SignupError, SignupResponse, UnlikeCommentData, UnlikeCommentError, UnlikeCommentResponse, UnlikePostData, UnlikePostError, UnlikePostResponse, UnlikeTalkData, UnlikeTalkError, UnlikeTalkResponse, UnsavePostData, UnsavePostError, UnsavePostResponse, UpdateMeData, UpdateMeError, UpdateMeResponse, UploadTalkImageData, UploadTalkImageError, UploadTalkImageResponse } from '../types.gen';
|
||||
import { addComment, addMyGak, addTalk, authConfig, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getTomorrowGuPage, getTomorrowPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, googleLogin, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listMyTalks, listPlaces, listPresets, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, scoreMyGak, signup, talkGroups, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from '../sdk.gen';
|
||||
import type { AddCommentData, AddCommentError, AddCommentResponse, AddMyGakData, AddMyGakError, AddMyGakResponse, AddTalkData, AddTalkError, AddTalkResponse, AuthConfigData, AuthConfigResponse, BlockTalkAuthorData, BlockTalkAuthorError, BlockTalkAuthorResponse, DeleteCommentData, DeleteCommentError, DeleteCommentResponse, DeleteMyGakData, DeleteMyGakError, DeleteMyGakResponse, DeleteTalkData, DeleteTalkError, DeleteTalkResponse, GetArticleData, GetArticleError, GetArticleResponse, GetFeedData, GetFeedError, GetFeedResponse, GetImageData, GetImageError, GetIndexData, GetIndexError, GetIndexResponse, GetPostData, GetPostError, GetPostResponse, GetSeasonWeekData, GetSeasonWeekResponse, GetSkyData, GetSkyError, GetSkyRankingData, GetSkyRankingResponse, GetSkyResponse, GetTalkImageData, GetTalkImageError, GetTodayGuPageData, GetTodayGuPageError, GetTodayGuPageResponse, GetTodayPageData, GetTodayPageError, GetTodayPageResponse, GetTomorrowGuPageData, GetTomorrowGuPageError, GetTomorrowGuPageResponse, GetTomorrowPageData, GetTomorrowPageError, GetTomorrowPageResponse, GetWatchSummaryData, GetWatchSummaryError, GetWatchSummaryResponse, GetWeatherNowData, GetWeatherNowError, GetWeatherNowResponse, GetWeatherTodayData, GetWeatherTodayError, GetWeatherTodayResponse, GetWeekData, GetWeekError, GetWeekRankingData, GetWeekRankingResponse, GetWeekResponse, GoogleLoginData, GoogleLoginError, GoogleLoginResponse, HealthzHealthzGetData, HealthzHealthzGetResponse, LikeCommentData, LikeCommentError, LikeCommentResponse, LikePostData, LikePostError, LikePostResponse, LikeTalkData, LikeTalkError, LikeTalkResponse, ListArticlesData, ListArticlesError, ListArticlesResponse, ListCommentsData, ListCommentsError, ListCommentsResponse, ListEventsData, ListEventsError, ListEventsResponse, ListIndicesData, ListIndicesError, ListIndicesResponse, ListMyGakData, ListMyGakError, ListMyGakResponse, ListMyTalksData, ListMyTalksError, ListMyTalksResponse, ListPlacesData, ListPlacesError, ListPlacesResponse, ListPresetsData, ListPresetsResponse, ListRegionsData, ListRegionsError, ListRegionsResponse, ListSavedData, ListSavedError, ListSavedResponse, ListTalksData, ListTalksError, ListTalksResponse, LoginData, LoginError, LoginResponse, LogoutData, LogoutError, LogoutResponse, MeData, MeError, MeResponse, NearestRegionData, NearestRegionError, NearestRegionResponse, RefreshData, RefreshError, RefreshResponse, ReportTalkData, ReportTalkError, ReportTalkResponse, SavePostData, SavePostError, SavePostResponse, ScoreMyGakData, ScoreMyGakError, ScoreMyGakResponse, SignupData, SignupError, SignupResponse, TalkGroupsData, TalkGroupsError, TalkGroupsResponse, UnlikeCommentData, UnlikeCommentError, UnlikeCommentResponse, UnlikePostData, UnlikePostError, UnlikePostResponse, UnlikeTalkData, UnlikeTalkError, UnlikeTalkResponse, UnsavePostData, UnsavePostError, UnsavePostResponse, UpdateMeData, UpdateMeError, UpdateMeResponse, UploadTalkImageData, UploadTalkImageError, UploadTalkImageResponse } from '../types.gen';
|
||||
|
||||
export type QueryKey<TOptions extends Options> = [
|
||||
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
|
||||
@@ -831,6 +831,24 @@ export const deleteMyGakMutation = (options?: Partial<Options<DeleteMyGakData>>)
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const talkGroupsQueryKey = (options?: Options<TalkGroupsData>) => createQueryKey('talkGroups', options);
|
||||
|
||||
/**
|
||||
* 오늘 피드 묶음 (동네 사람들 + 주제별, 가까운 동네·덜 지난 글 먼저, 한 사람 한 장)
|
||||
*/
|
||||
export const talkGroupsOptions = (options?: Options<TalkGroupsData>) => queryOptions<TalkGroupsResponse, TalkGroupsError, TalkGroupsResponse, ReturnType<typeof talkGroupsQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await talkGroups({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: talkGroupsQueryKey(options)
|
||||
});
|
||||
|
||||
export const listTalksQueryKey = (options?: Options<ListTalksData>) => createQueryKey('listTalks', options);
|
||||
|
||||
/**
|
||||
@@ -1136,6 +1154,42 @@ export const getTodayGuPageOptions = (options: Options<GetTodayGuPageData>) => q
|
||||
queryKey: getTodayGuPageQueryKey(options)
|
||||
});
|
||||
|
||||
export const getTomorrowPageQueryKey = (options: Options<GetTomorrowPageData>) => createQueryKey('getTomorrowPage', options);
|
||||
|
||||
/**
|
||||
* 지역 내일 날씨 페이지: 정적 HTML 에 내일 예보를 채운다 (nginx 가 /tomorrow/... 를 넘김)
|
||||
*/
|
||||
export const getTomorrowPageOptions = (options: Options<GetTomorrowPageData>) => queryOptions<GetTomorrowPageResponse, GetTomorrowPageError, GetTomorrowPageResponse, ReturnType<typeof getTomorrowPageQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getTomorrowPage({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getTomorrowPageQueryKey(options)
|
||||
});
|
||||
|
||||
export const getTomorrowGuPageQueryKey = (options: Options<GetTomorrowGuPageData>) => createQueryKey('getTomorrowGuPage', options);
|
||||
|
||||
/**
|
||||
* 구로 나뉜 시의 구 내일 날씨 페이지
|
||||
*/
|
||||
export const getTomorrowGuPageOptions = (options: Options<GetTomorrowGuPageData>) => queryOptions<GetTomorrowGuPageResponse, GetTomorrowGuPageError, GetTomorrowGuPageResponse, ReturnType<typeof getTomorrowGuPageQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getTomorrowGuPage({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getTomorrowGuPageQueryKey(options)
|
||||
});
|
||||
|
||||
export const healthzHealthzGetQueryKey = (options?: Options<HealthzHealthzGetData>) => createQueryKey('healthzHealthzGet', options);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
export { addComment, addMyGak, addTalk, authConfig, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, googleLogin, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listMyTalks, listPlaces, listPresets, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, scoreMyGak, signup, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from './sdk.gen';
|
||||
export { type AddCommentData, type AddCommentError, type AddCommentErrors, type AddCommentResponse, type AddCommentResponses, type AddMyGakData, type AddMyGakError, type AddMyGakErrors, type AddMyGakResponse, type AddMyGakResponses, type AddTalkData, type AddTalkError, type AddTalkErrors, type AddTalkResponse, type AddTalkResponses, type AirData, AirGrade, ArticleCategory, type ArticleSummary, type AuthConfigData, type AuthConfigResponse, type AuthConfigResponses, AuthProvider, type BandArticle, type BandEvent, type Bands, type BestTime, type BlockTalkAuthorData, type BlockTalkAuthorError, type BlockTalkAuthorErrors, type BlockTalkAuthorResponse, type BlockTalkAuthorResponses, type BodyUploadTalkImageV1TalkImagePost, type ClientOptions, type CommentData, type CommuteData, Confidence, type Cut, type DayData, type DeleteCommentData, type DeleteCommentError, type DeleteCommentErrors, type DeleteCommentResponse, type DeleteCommentResponses, type DeleteMyGakData, type DeleteMyGakError, type DeleteMyGakErrors, type DeleteMyGakResponse, type DeleteMyGakResponses, type DeleteTalkData, type DeleteTalkError, type DeleteTalkErrors, type DeleteTalkResponse, type DeleteTalkResponses, type ErrorInfo, type EventData, type Factor, type GakSlide, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type GetFeedData, type GetFeedError, type GetFeedErrors, type GetFeedResponse, type GetFeedResponses, type GetImageData, type GetImageError, type GetImageErrors, type GetImageResponses, type GetIndexData, type GetIndexError, type GetIndexErrors, type GetIndexResponse, type GetIndexResponses, type GetPostData, type GetPostError, type GetPostErrors, type GetPostResponse, type GetPostResponses, type GetSeasonWeekData, type GetSeasonWeekResponse, type GetSeasonWeekResponses, type GetSkyData, type GetSkyError, type GetSkyErrors, type GetSkyRankingData, type GetSkyRankingResponse, type GetSkyRankingResponses, type GetSkyResponse, type GetSkyResponses, type GetTalkImageData, type GetTalkImageError, type GetTalkImageErrors, type GetTalkImageResponses, type GetTodayGuPageData, type GetTodayGuPageError, type GetTodayGuPageErrors, type GetTodayGuPageResponse, type GetTodayGuPageResponses, type GetTodayPageData, type GetTodayPageError, type GetTodayPageErrors, type GetTodayPageResponse, type GetTodayPageResponses, type GetWatchSummaryData, type GetWatchSummaryError, type GetWatchSummaryErrors, type GetWatchSummaryResponse, type GetWatchSummaryResponses, type GetWeatherNowData, type GetWeatherNowError, type GetWeatherNowErrors, type GetWeatherNowResponse, type GetWeatherNowResponses, type GetWeatherTodayData, type GetWeatherTodayError, type GetWeatherTodayErrors, type GetWeatherTodayResponse, type GetWeatherTodayResponses, type GetWeekData, type GetWeekError, type GetWeekErrors, type GetWeekRankingData, type GetWeekRankingResponse, type GetWeekRankingResponses, type GetWeekResponse, type GetWeekResponses, type GoogleLoginData, type GoogleLoginError, type GoogleLoginErrors, type GoogleLoginResponse, type GoogleLoginResponses, type HealthzHealthzGetData, type HealthzHealthzGetResponse, type HealthzHealthzGetResponses, type Hero, type HeroStat, type HeroTomorrow, type HourCell, type HoursSlide, type HttpValidationError, IndexCategory, type IndexSummary, type LikeCommentData, type LikeCommentError, type LikeCommentErrors, type LikeCommentResponse, type LikeCommentResponses, type LikePostData, type LikePostError, type LikePostErrors, type LikePostResponse, type LikePostResponses, type LikeTalkData, type LikeTalkError, type LikeTalkErrors, type LikeTalkResponse, type LikeTalkResponses, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponses, type ListCommentsData, type ListCommentsError, type ListCommentsErrors, type ListCommentsResponse, type ListCommentsResponses, type ListEventsData, type ListEventsError, type ListEventsErrors, type ListEventsResponse, type ListEventsResponses, type ListIndicesData, type ListIndicesError, type ListIndicesErrors, type ListIndicesResponse, type ListIndicesResponses, type ListMyGakData, type ListMyGakError, type ListMyGakErrors, type ListMyGakResponse, type ListMyGakResponses, type ListMyTalksData, type ListMyTalksError, type ListMyTalksErrors, type ListMyTalksResponse, type ListMyTalksResponses, type ListPlacesData, type ListPlacesError, type ListPlacesErrors, type ListPlacesResponse, type ListPlacesResponses, type ListPresetsData, type ListPresetsResponse, type ListPresetsResponses, type ListRegionsData, type ListRegionsError, type ListRegionsErrors, type ListRegionsResponse, type ListRegionsResponses, type ListSavedData, type ListSavedError, type ListSavedErrors, type ListSavedResponse, type ListSavedResponses, type ListTalksData, type ListTalksError, type ListTalksErrors, type ListTalksResponse, type ListTalksResponses, type LoginData, type LoginError, type LoginErrors, type LogLine truncated
|
||||
export { addComment, addMyGak, addTalk, authConfig, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getTomorrowGuPage, getTomorrowPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, googleLogin, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listMyTalks, listPlaces, listPresets, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, scoreMyGak, signup, talkGroups, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from './sdk.gen';
|
||||
export { type AddCommentData, type AddCommentError, type AddCommentErrors, type AddCommentResponse, type AddCommentResponses, type AddMyGakData, type AddMyGakError, type AddMyGakErrors, type AddMyGakResponse, type AddMyGakResponses, type AddTalkData, type AddTalkError, type AddTalkErrors, type AddTalkResponse, type AddTalkResponses, type AirData, AirGrade, ArticleCategory, type ArticleSummary, type AuthConfigData, type AuthConfigResponse, type AuthConfigResponses, AuthProvider, type BandArticle, type BandEvent, type Bands, type BestTime, type BlockTalkAuthorData, type BlockTalkAuthorError, type BlockTalkAuthorErrors, type BlockTalkAuthorResponse, type BlockTalkAuthorResponses, type BodyUploadTalkImageV1TalkImagePost, type ClientOptions, type CommentData, type CommuteData, Confidence, type Cut, type DayData, type DeleteCommentData, type DeleteCommentError, type DeleteCommentErrors, type DeleteCommentResponse, type DeleteCommentResponses, type DeleteMyGakData, type DeleteMyGakError, type DeleteMyGakErrors, type DeleteMyGakResponse, type DeleteMyGakResponses, type DeleteTalkData, type DeleteTalkError, type DeleteTalkErrors, type DeleteTalkResponse, type DeleteTalkResponses, type ErrorInfo, type EventData, type Factor, type GakSlide, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type GetFeedData, type GetFeedError, type GetFeedErrors, type GetFeedResponse, type GetFeedResponses, type GetImageData, type GetImageError, type GetImageErrors, type GetImageResponses, type GetIndexData, type GetIndexError, type GetIndexErrors, type GetIndexResponse, type GetIndexResponses, type GetPostData, type GetPostError, type GetPostErrors, type GetPostResponse, type GetPostResponses, type GetSeasonWeekData, type GetSeasonWeekResponse, type GetSeasonWeekResponses, type GetSkyData, type GetSkyError, type GetSkyErrors, type GetSkyRankingData, type GetSkyRankingResponse, type GetSkyRankingResponses, type GetSkyResponse, type GetSkyResponses, type GetTalkImageData, type GetTalkImageError, type GetTalkImageErrors, type GetTalkImageResponses, type GetTodayGuPageData, type GetTodayGuPageError, type GetTodayGuPageErrors, type GetTodayGuPageResponse, type GetTodayGuPageResponses, type GetTodayPageData, type GetTodayPageError, type GetTodayPageErrors, type GetTodayPageResponse, type GetTodayPageResponses, type GetTomorrowGuPageData, type GetTomorrowGuPageError, type GetTomorrowGuPageErrors, type GetTomorrowGuPageResponse, type GetTomorrowGuPageResponses, type GetTomorrowPageData, type GetTomorrowPageError, type GetTomorrowPageErrors, type GetTomorrowPageResponse, type GetTomorrowPageResponses, type GetWatchSummaryData, type GetWatchSummaryError, type GetWatchSummaryErrors, type GetWatchSummaryResponse, type GetWatchSummaryResponses, type GetWeatherNowData, type GetWeatherNowError, type GetWeatherNowErrors, type GetWeatherNowResponse, type GetWeatherNowResponses, type GetWeatherTodayData, type GetWeatherTodayError, type GetWeatherTodayErrors, type GetWeatherTodayResponse, type GetWeatherTodayResponses, type GetWeekData, type GetWeekError, type GetWeekErrors, type GetWeekRankingData, type GetWeekRankingResponse, type GetWeekRankingResponses, type GetWeekResponse, type GetWeekResponses, type GoogleLoginData, type GoogleLoginError, type GoogleLoginErrors, type GoogleLoginResponse, type GoogleLoginResponses, type HealthzHealthzGetData, type HealthzHealthzGetResponse, type HealthzHealthzGetResponses, type Hero, type HeroStat, type HeroTomorrow, type HourCell, type HoursSlide, type HttpValidationError, IndexCategory, type IndexSummary, type LikeCommentData, type LikeCommentError, type LikeCommentErrors, type LikeCommentResponse, type LikeCommentResponses, type LikePostData, type LikePostError, type LikePostErrors, type LikePostResponse, type LikePostResponses, type LikeTalkData, type LikeTalkError, type LikeTalkErrors, type LikeTalkResponse, type LikeTalkResponses, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponses, type ListCommentsData, type ListCommentsError, type ListCommentsErrors, type ListCommentsResponse, type ListCommentsResponses, type ListEventsData, type ListEventsError, type ListEventsErrors, type ListEventsResponse, type ListEventsResponses, type ListIndicesData, type ListIndicesError, type ListIndicesErrors, type ListIndicesResponse, type ListIndicesResponses, type ListMyGakData, type ListMyGakError, type ListMyGakErrors, type ListMyGakResponse, type ListMyGakResponses, type ListMyTalksData, type ListMyTalksError, type ListMyTalksErrors, type ListMyTalksResponse, type ListMyTalksResponses, type ListPlacesData, type ListPlacesError, type ListPlacesErrors, type ListPlacesResponse, type ListPlacesResponses, type ListPresetsData, type ListPresetsResponse, type ListPresetsResponses, type ListRegionsData, type ListRegionsError, type ListRegionsErrors, type ListRegionsResponse, type ListRegionsLine truncated
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { type Client, type ClientMeta, formDataBodySerializer, type Options as Options2, type RequestResult, type TDataShape } from './client';
|
||||
import { client } from './client.gen';
|
||||
import type { AddCommentData, AddCommentErrors, AddCommentResponses, AddMyGakData, AddMyGakErrors, AddMyGakResponses, AddTalkData, AddTalkErrors, AddTalkResponses, AuthConfigData, AuthConfigResponses, BlockTalkAuthorData, BlockTalkAuthorErrors, BlockTalkAuthorResponses, DeleteCommentData, DeleteCommentErrors, DeleteCommentResponses, DeleteMyGakData, DeleteMyGakErrors, DeleteMyGakResponses, DeleteTalkData, DeleteTalkErrors, DeleteTalkResponses, GetArticleData, GetArticleErrors, GetArticleResponses, GetFeedData, GetFeedErrors, GetFeedResponses, GetImageData, GetImageErrors, GetImageResponses, GetIndexData, GetIndexErrors, GetIndexResponses, GetPostData, GetPostErrors, GetPostResponses, GetSeasonWeekData, GetSeasonWeekResponses, GetSkyData, GetSkyErrors, GetSkyRankingData, GetSkyRankingResponses, GetSkyResponses, GetTalkImageData, GetTalkImageErrors, GetTalkImageResponses, GetTodayGuPageData, GetTodayGuPageErrors, GetTodayGuPageResponses, GetTodayPageData, GetTodayPageErrors, GetTodayPageResponses, GetWatchSummaryData, GetWatchSummaryErrors, GetWatchSummaryResponses, GetWeatherNowData, GetWeatherNowErrors, GetWeatherNowResponses, GetWeatherTodayData, GetWeatherTodayErrors, GetWeatherTodayResponses, GetWeekData, GetWeekErrors, GetWeekRankingData, GetWeekRankingResponses, GetWeekResponses, GoogleLoginData, GoogleLoginErrors, GoogleLoginResponses, HealthzHealthzGetData, HealthzHealthzGetResponses, LikeCommentData, LikeCommentErrors, LikeCommentResponses, LikePostData, LikePostErrors, LikePostResponses, LikeTalkData, LikeTalkErrors, LikeTalkResponses, ListArticlesData, ListArticlesErrors, ListArticlesResponses, ListCommentsData, ListCommentsErrors, ListCommentsResponses, ListEventsData, ListEventsErrors, ListEventsResponses, ListIndicesData, ListIndicesErrors, ListIndicesResponses, ListMyGakData, ListMyGakErrors, ListMyGakResponses, ListMyTalksData, ListMyTalksErrors, ListMyTalksResponses, ListPlacesData, ListPlacesErrors, ListPlacesResponses, ListPresetsData, ListPresetsResponses, ListRegionsData, ListRegionsErrors, ListRegionsResponses, ListSavedData, ListSavedErrors, ListSavedResponses, ListTalksData, ListTalksErrors, ListTalksResponses, LoginData, LoginErrors, LoginResponses, LogoutData, LogoutErrors, LogoutResponses, MeData, MeErrors, MeResponses, NearestRegionData, NearestRegionErrors, NearestRegionResponses, RefreshData, RefreshErrors, RefreshResponses, ReportTalkData, ReportTalkErrors, ReportTalkResponses, SavePostData, SavePostErrors, SavePostResponses, ScoreMyGakData, ScoreMyGakErrors, ScoreMyGakResponses, SignupData, SignupErrors, SignupResponses, UnlikeCommentData, UnlikeCommentErrors, UnlikeCommentResponses, UnlikePostData, UnlikePostErrors, UnlikePostResponses, UnlikeTalkData, UnlikeTalkErrors, UnlikeTalkResponses, UnsavePostData, UnsavePostErrors, UnsavePostResponses, UpdateMeData, UpdateMeErrors, UpdateMeResponses, UploadTalkImageData, UploadTalkImageErrors, UploadTalkImageResponses } from './types.gen';
|
||||
import type { AddCommentData, AddCommentErrors, AddCommentResponses, AddMyGakData, AddMyGakErrors, AddMyGakResponses, AddTalkData, AddTalkErrors, AddTalkResponses, AuthConfigData, AuthConfigResponses, BlockTalkAuthorData, BlockTalkAuthorErrors, BlockTalkAuthorResponses, DeleteCommentData, DeleteCommentErrors, DeleteCommentResponses, DeleteMyGakData, DeleteMyGakErrors, DeleteMyGakResponses, DeleteTalkData, DeleteTalkErrors, DeleteTalkResponses, GetArticleData, GetArticleErrors, GetArticleResponses, GetFeedData, GetFeedErrors, GetFeedResponses, GetImageData, GetImageErrors, GetImageResponses, GetIndexData, GetIndexErrors, GetIndexResponses, GetPostData, GetPostErrors, GetPostResponses, GetSeasonWeekData, GetSeasonWeekResponses, GetSkyData, GetSkyErrors, GetSkyRankingData, GetSkyRankingResponses, GetSkyResponses, GetTalkImageData, GetTalkImageErrors, GetTalkImageResponses, GetTodayGuPageData, GetTodayGuPageErrors, GetTodayGuPageResponses, GetTodayPageData, GetTodayPageErrors, GetTodayPageResponses, GetTomorrowGuPageData, GetTomorrowGuPageErrors, GetTomorrowGuPageResponses, GetTomorrowPageData, GetTomorrowPageErrors, GetTomorrowPageResponses, GetWatchSummaryData, GetWatchSummaryErrors, GetWatchSummaryResponses, GetWeatherNowData, GetWeatherNowErrors, GetWeatherNowResponses, GetWeatherTodayData, GetWeatherTodayErrors, GetWeatherTodayResponses, GetWeekData, GetWeekErrors, GetWeekRankingData, GetWeekRankingResponses, GetWeekResponses, GoogleLoginData, GoogleLoginErrors, GoogleLoginResponses, HealthzHealthzGetData, HealthzHealthzGetResponses, LikeCommentData, LikeCommentErrors, LikeCommentResponses, LikePostData, LikePostErrors, LikePostResponses, LikeTalkData, LikeTalkErrors, LikeTalkResponses, ListArticlesData, ListArticlesErrors, ListArticlesResponses, ListCommentsData, ListCommentsErrors, ListCommentsResponses, ListEventsData, ListEventsErrors, ListEventsResponses, ListIndicesData, ListIndicesErrors, ListIndicesResponses, ListMyGakData, ListMyGakErrors, ListMyGakResponses, ListMyTalksData, ListMyTalksErrors, ListMyTalksResponses, ListPlacesData, ListPlacesErrors, ListPlacesResponses, ListPresetsData, ListPresetsResponses, ListRegionsData, ListRegionsErrors, ListRegionsResponses, ListSavedData, ListSavedErrors, ListSavedResponses, ListTalksData, ListTalksErrors, ListTalksResponses, LoginData, LoginErrors, LoginResponses, LogoutData, LogoutErrors, LogoutResponses, MeData, MeErrors, MeResponses, NearestRegionData, NearestRegionErrors, NearestRegionResponses, RefreshData, RefreshErrors, RefreshResponses, ReportTalkData, ReportTalkErrors, ReportTalkResponses, SavePostData, SavePostErrors, SavePostResponses, ScoreMyGakData, ScoreMyGakErrors, ScoreMyGakResponses, SignupData, SignupErrors, SignupResponses, TalkGroupsData, TalkGroupsErrors, TalkGroupsResponses, UnlikeCommentData, UnlikeCommentErrors, UnlikeCommentResponses, UnlikePostData, UnlikePostErrors, UnlikePostResponses, UnlikeTalkData, UnlikeTalkErrors, UnlikeTalkResponses, UnsavePostData, UnsavePostErrors, UnsavePostResponses, UpdateMeData, UpdateMeErrors, UpdateMeResponses, UploadTalkImageData, UploadTalkImageErrors, UploadTalkImageResponses } from './types.gen';
|
||||
|
||||
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
|
||||
/**
|
||||
@@ -274,6 +274,11 @@ export const scoreMyGak = <ThrowOnError extends boolean = true>(options: Options
|
||||
*/
|
||||
export const deleteMyGak = <ThrowOnError extends boolean = true>(options: Options<DeleteMyGakData, ThrowOnError>): RequestResult<DeleteMyGakResponses, DeleteMyGakErrors, ThrowOnError> => (options.client ?? client).delete<DeleteMyGakResponses, DeleteMyGakErrors, ThrowOnError>({ url: '/v1/my-gak/{my_gak_id}', ...options });
|
||||
|
||||
/**
|
||||
* 오늘 피드 묶음 (동네 사람들 + 주제별, 가까운 동네·덜 지난 글 먼저, 한 사람 한 장)
|
||||
*/
|
||||
export const talkGroups = <ThrowOnError extends boolean = true>(options?: Options<TalkGroupsData, ThrowOnError>): RequestResult<TalkGroupsResponses, TalkGroupsErrors, ThrowOnError> => (options?.client ?? client).get<TalkGroupsResponses, TalkGroupsErrors, ThrowOnError>({ url: '/v1/talk/groups', ...options });
|
||||
|
||||
/**
|
||||
* 동네 이야기 (전국 최신순, 보는 동네와 같은 시도 글은 앞으로, 같은 사람 글은 띄움, 로그인 없이 보기)
|
||||
*/
|
||||
@@ -366,6 +371,16 @@ export const getTodayPage = <ThrowOnError extends boolean = true>(options: Optio
|
||||
*/
|
||||
export const getTodayGuPage = <ThrowOnError extends boolean = true>(options: Options<GetTodayGuPageData, ThrowOnError>): RequestResult<GetTodayGuPageResponses, GetTodayGuPageErrors, ThrowOnError> => (options.client ?? client).get<GetTodayGuPageResponses, GetTodayGuPageErrors, ThrowOnError>({ url: '/v1/seo/today/{sido}/{place}/{gu}', ...options });
|
||||
|
||||
/**
|
||||
* 지역 내일 날씨 페이지: 정적 HTML 에 내일 예보를 채운다 (nginx 가 /tomorrow/... 를 넘김)
|
||||
*/
|
||||
export const getTomorrowPage = <ThrowOnError extends boolean = true>(options: Options<GetTomorrowPageData, ThrowOnError>): RequestResult<GetTomorrowPageResponses, GetTomorrowPageErrors, ThrowOnError> => (options.client ?? client).get<GetTomorrowPageResponses, GetTomorrowPageErrors, ThrowOnError>({ url: '/v1/seo/tomorrow/{sido}/{place}', ...options });
|
||||
|
||||
/**
|
||||
* 구로 나뉜 시의 구 내일 날씨 페이지
|
||||
*/
|
||||
export const getTomorrowGuPage = <ThrowOnError extends boolean = true>(options: Options<GetTomorrowGuPageData, ThrowOnError>): RequestResult<GetTomorrowGuPageResponses, GetTomorrowGuPageErrors, ThrowOnError> => (options.client ?? client).get<GetTomorrowGuPageResponses, GetTomorrowGuPageErrors, ThrowOnError>({ url: '/v1/seo/tomorrow/{sido}/{place}/{gu}', ...options });
|
||||
|
||||
/**
|
||||
* 헬스체크
|
||||
*/
|
||||
|
||||
@@ -1542,6 +1542,10 @@ export type ReqTalk = {
|
||||
* 먼저 올린 사진 주소 (POST /v1/talk/image 결과)
|
||||
*/
|
||||
image?: string | null;
|
||||
/**
|
||||
* 글 주제. 안 고르면 동네 이야기
|
||||
*/
|
||||
topic?: TalkTopic;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2161,6 +2165,23 @@ export type ResTalk = {
|
||||
talk?: TalkData | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Res_TalkGroups
|
||||
*/
|
||||
export type ResTalkGroups = {
|
||||
result?: ErrorInfo;
|
||||
/**
|
||||
* Msg
|
||||
*/
|
||||
msg?: string | null;
|
||||
/**
|
||||
* Groups
|
||||
*
|
||||
* 동네 사람들 묶음은 늘 있고(비어 있을 수 있음), 주제 묶음은 3장 이상일 때만
|
||||
*/
|
||||
groups?: Array<TalkGroup>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Res_TalkImage
|
||||
*/
|
||||
@@ -2869,6 +2890,7 @@ export type TalkData = {
|
||||
* 올린 사진 주소
|
||||
*/
|
||||
image?: string | null;
|
||||
topic?: TalkTopic;
|
||||
/**
|
||||
* Like Count
|
||||
*/
|
||||
@@ -2887,6 +2909,22 @@ export type TalkData = {
|
||||
created_at: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* TalkGroup
|
||||
*/
|
||||
export type TalkGroup = {
|
||||
/**
|
||||
* Topic
|
||||
*
|
||||
* 0 이면 '동네 사람들'(모든 주제), 아니면 TalkTopic
|
||||
*/
|
||||
topic: number;
|
||||
/**
|
||||
* Talks
|
||||
*/
|
||||
talks?: Array<TalkData>;
|
||||
};
|
||||
|
||||
/**
|
||||
* TalkReport
|
||||
*/
|
||||
@@ -2914,6 +2952,41 @@ export const TalkReport = {
|
||||
*/
|
||||
export type TalkReport = typeof TalkReport[keyof typeof TalkReport];
|
||||
|
||||
/**
|
||||
* TalkTopic
|
||||
*
|
||||
* 사람 글 주제. 안 고르면 동네 이야기. 피드에서 같은 주제 포스트 옆에 묶어 보여 준다
|
||||
*/
|
||||
export const TalkTopic = {
|
||||
/**
|
||||
* LOCAL
|
||||
*/
|
||||
LOCAL: 1,
|
||||
/**
|
||||
* SKY
|
||||
*/
|
||||
SKY: 2,
|
||||
/**
|
||||
* RAIN
|
||||
*/
|
||||
RAIN: 3,
|
||||
/**
|
||||
* FOLIAGE
|
||||
*/
|
||||
FOLIAGE: 4,
|
||||
/**
|
||||
* OUTFIT
|
||||
*/
|
||||
OUTFIT: 5
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* TalkTopic
|
||||
*
|
||||
* 사람 글 주제. 안 고르면 동네 이야기. 피드에서 같은 주제 포스트 옆에 묶어 보여 준다
|
||||
*/
|
||||
export type TalkTopic = typeof TalkTopic[keyof typeof TalkTopic];
|
||||
|
||||
/**
|
||||
* TermData
|
||||
*/
|
||||
@@ -4726,6 +4799,44 @@ export type DeleteMyGakResponses = {
|
||||
|
||||
export type DeleteMyGakResponse = DeleteMyGakResponses[keyof DeleteMyGakResponses];
|
||||
|
||||
export type TalkGroupsData = {
|
||||
body?: never;
|
||||
headers?: {
|
||||
/**
|
||||
* Authorization
|
||||
*/
|
||||
authorization?: string | null;
|
||||
};
|
||||
path?: never;
|
||||
query?: {
|
||||
/**
|
||||
* Region
|
||||
*
|
||||
* 보는 사람의 구 행정코드
|
||||
*/
|
||||
region?: string | null;
|
||||
};
|
||||
url: '/v1/talk/groups';
|
||||
};
|
||||
|
||||
export type TalkGroupsErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type TalkGroupsError = TalkGroupsErrors[keyof TalkGroupsErrors];
|
||||
|
||||
export type TalkGroupsResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: ResTalkGroups;
|
||||
};
|
||||
|
||||
export type TalkGroupsResponse = TalkGroupsResponses[keyof TalkGroupsResponses];
|
||||
|
||||
export type ListTalksData = {
|
||||
body?: never;
|
||||
headers?: {
|
||||
@@ -4742,6 +4853,12 @@ export type ListTalksData = {
|
||||
* 보는 사람의 구 행정코드
|
||||
*/
|
||||
region?: string | null;
|
||||
/**
|
||||
* Topic
|
||||
*
|
||||
* 이 주제 글만. 없으면 전체
|
||||
*/
|
||||
topic?: TalkTopic | null;
|
||||
/**
|
||||
* Cursor
|
||||
*/
|
||||
@@ -5222,6 +5339,78 @@ export type GetTodayGuPageResponses = {
|
||||
|
||||
export type GetTodayGuPageResponse = GetTodayGuPageResponses[keyof GetTodayGuPageResponses];
|
||||
|
||||
export type GetTomorrowPageData = {
|
||||
body?: never;
|
||||
path: {
|
||||
/**
|
||||
* Sido
|
||||
*/
|
||||
sido: string;
|
||||
/**
|
||||
* Place
|
||||
*/
|
||||
place: string;
|
||||
};
|
||||
query?: never;
|
||||
url: '/v1/seo/tomorrow/{sido}/{place}';
|
||||
};
|
||||
|
||||
export type GetTomorrowPageErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type GetTomorrowPageError = GetTomorrowPageErrors[keyof GetTomorrowPageErrors];
|
||||
|
||||
export type GetTomorrowPageResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: string;
|
||||
};
|
||||
|
||||
export type GetTomorrowPageResponse = GetTomorrowPageResponses[keyof GetTomorrowPageResponses];
|
||||
|
||||
export type GetTomorrowGuPageData = {
|
||||
body?: never;
|
||||
path: {
|
||||
/**
|
||||
* Sido
|
||||
*/
|
||||
sido: string;
|
||||
/**
|
||||
* Place
|
||||
*/
|
||||
place: string;
|
||||
/**
|
||||
* Gu
|
||||
*/
|
||||
gu: string;
|
||||
};
|
||||
query?: never;
|
||||
url: '/v1/seo/tomorrow/{sido}/{place}/{gu}';
|
||||
};
|
||||
|
||||
export type GetTomorrowGuPageErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type GetTomorrowGuPageError = GetTomorrowGuPageErrors[keyof GetTomorrowGuPageErrors];
|
||||
|
||||
export type GetTomorrowGuPageResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: string;
|
||||
};
|
||||
|
||||
export type GetTomorrowGuPageResponse = GetTomorrowGuPageResponses[keyof GetTomorrowGuPageResponses];
|
||||
|
||||
export type HealthzHealthzGetData = {
|
||||
body?: never;
|
||||
path?: never;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { useSearchParams } from 'react-router'
|
||||
import type { TalkTopic } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { TalkCard } from './talk'
|
||||
import { TOPICS, useTopicTalks } from './talkState'
|
||||
import { Sec } from './ui'
|
||||
|
||||
/** 주제별 사람 글: 위 주제 탭, 아래 글 목록. 피드 묶음의 '전체 보기'가 ?topic= 으로 연다 */
|
||||
export function TalkPage() {
|
||||
const [params, setParams] = useSearchParams()
|
||||
const raw = Number(params.get('topic'))
|
||||
const topic = TOPICS.some(([k]) => k === raw) ? (raw as TalkTopic) : undefined
|
||||
const { talks, loaded, more, loadMore } = useTopicTalks(topic)
|
||||
const tabs: (readonly [TalkTopic | undefined, string])[] = [[undefined, '전체'], ...TOPICS]
|
||||
|
||||
return (
|
||||
<section aria-label="동네 사람들 글">
|
||||
<Sec title="동네 사람들 글" sub="가까운 동네 글부터 보여요" />
|
||||
<div className="flex flex-wrap gap-1.5 px-4 pb-1" role="tablist" aria-label="글 주제">
|
||||
{tabs.map(([k, label]) => (
|
||||
<button
|
||||
key={label}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={topic === k}
|
||||
onClick={() => setParams(k ? { topic: String(k) } : {}, { replace: true })}
|
||||
className={cx('cursor-pointer rounded-full px-3 py-1.5 text-[13px] font-extrabold', topic === k ? 'bg-(--ink) text-white' : 'bg-white text-(--ink2)')}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{loaded && !talks.length && <p className="mx-4 mt-6 text-center text-[14px] font-semibold text-(--ink3)">아직 이 주제 글이 없어요. 오늘 탭에서 첫 글을 써 주세요.</p>}
|
||||
{talks.map((t) => (
|
||||
<TalkCard key={`${t.talk_id}:${t.liked}:${t.like_count}`} t={t} />
|
||||
))}
|
||||
{more && (
|
||||
<button type="button" onClick={() => loadMore()} className="mx-3 mt-3 w-[calc(100%-1.5rem)] cursor-pointer rounded-[14px] bg-white py-2.5 text-[13.5px] font-extrabold text-(--ink2)">
|
||||
더 보기
|
||||
</button>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -3,8 +3,10 @@ import { Link, useLocation } from 'react-router'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getFeedOptions, getWeatherTodayOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import {
|
||||
PostType,
|
||||
RainType,
|
||||
Sky,
|
||||
TalkTopic,
|
||||
type BandArticle,
|
||||
type BandEvent,
|
||||
type Hero as HeroData,
|
||||
@@ -22,8 +24,8 @@ import { MyGakRow } from './myGak'
|
||||
import { fromShare } from './myGakState'
|
||||
import { PostCard, PostCardSkel, PostFrame } from './Post'
|
||||
import { usePinnedLike, type PinnedKey } from './pinnedLike'
|
||||
import { FeedComposer, TalkCard } from './talk'
|
||||
import { useFeedTalks } from './talkState'
|
||||
import { FeedComposer, NearTalks, TalkCard, TalkGroup } from './talk'
|
||||
import { topicName, useTalkGroups } from './talkState'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { useSky } from './skyContext'
|
||||
@@ -365,7 +367,7 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps
|
||||
<span className="b-cloud b-bob inset-0" />
|
||||
</span>
|
||||
))}
|
||||
<div className="b-fall absolute top-2 left-1/2 -ml-16 aspect-square w-32" style={fall('0s', '5.6s')}>
|
||||
<div className={'b-fall absolute top-2 left-1/2 -ml-16 aspect-square w-32'} style={fall('0s', '5.6s')}>
|
||||
<div className="b-sun b-bob relative grid size-full place-items-center rounded-full text-center">
|
||||
{/* 안 보이는 쪽을 덮어 오늘 밤 달 모양으로 */}
|
||||
{moon && (
|
||||
@@ -572,8 +574,6 @@ function SeasonBand({ news, post }: { news: BandArticle[]; post?: PostReaction |
|
||||
)
|
||||
}
|
||||
|
||||
const TALK_EVERY = 3
|
||||
|
||||
export function TodayPage() {
|
||||
const { region } = useRegion()
|
||||
const feed = useQuery(getFeedOptions({ query: { region: region.code } }))
|
||||
@@ -588,19 +588,18 @@ export function TodayPage() {
|
||||
const nowAt = f?.hero?.now_at
|
||||
const load = loadOf(feed)
|
||||
const [mine, setMine] = useState<TalkData[]>([])
|
||||
// 사람들이 쓴 글은 4·7·10번째 포스트 뒤에 하나씩(3번째 뒤 행사 띠와 안 붙게), 남은 글은 피드 끝에. 방금 올린 내 글은 글쓰기 칸 아래에 따로 있으니 빼고
|
||||
const feedTalks = useFeedTalks()
|
||||
const talks = feedTalks.talks.filter((t) => !mine.some((m) => m.talk_id === t.talk_id))
|
||||
const between = Math.max(0, Math.floor((posts.length - 1) / TALK_EVERY))
|
||||
const moreRef = useRef<HTMLDivElement>(null)
|
||||
const { more, loadMore } = feedTalks
|
||||
useEffect(() => {
|
||||
const el = moreRef.current
|
||||
if (!el || !more) return
|
||||
const io = new IntersectionObserver((es) => es.some((e) => e.isIntersecting) && loadMore(), { rootMargin: '600px' })
|
||||
io.observe(el)
|
||||
return () => io.disconnect()
|
||||
}, [more, loadMore])
|
||||
// 사람 글은 묶음으로: '동네 사람들'은 오늘의 각 아래, 주제 묶음은 같은 주제 포스트 아래. 방금 올린 내 글은 글쓰기 칸 아래에 따로 있으니 빼고
|
||||
const talkGroups = useTalkGroups()
|
||||
const groupOf = (topic: number) => (talkGroups.groups.get(topic) ?? []).filter((t) => !mine.some((m) => m.talk_id === t.talk_id))
|
||||
const group = (topic: number) => {
|
||||
const talks = groupOf(topic)
|
||||
return talks.length ? <TalkGroup key={`talk-${topic}`} title={topicName(topic)} topic={topic} talks={talks} /> : null
|
||||
}
|
||||
// 비·눈이 오거나 2시간 안에 올 때만 비·눈 묶음을 히어로 바로 아래로
|
||||
const at = nowAt ? Date.parse(nowAt) : 0
|
||||
const nowSlot = (today.data?.slots ?? []).filter((x) => x.temp_c != null).reduce<WeatherSlot | undefined>((a, b) => (!a || Math.abs(Date.parse(b.at) - at) < Math.abs(Date.parse(a.at) - at) ? b : a), undefined)
|
||||
const raining = ['rain', 'snow', 'sleet'].includes(weatherOf(nowSlot)) || !!f?.hero?.will_rain_2h
|
||||
const sunsetAt = posts.findIndex((p) => p.post_type === PostType.SUNSET)
|
||||
|
||||
useEffect(() => {
|
||||
window.scrollTo({ top: 0 })
|
||||
@@ -623,6 +622,17 @@ export function TodayPage() {
|
||||
[9, bands?.season?.length ? <SeasonBand key="season" news={bands.season} post={f?.season_post} /> : null],
|
||||
]
|
||||
|
||||
// 사람 글 묶음은 포스트 사이사이에 하나씩: 묶음·띠·단풍 카드가 이미 붙는 자리와 바로 앞 자리는 건너뛰어 가로 목록이 연달아 나오지 않게
|
||||
const spreadTopics = [TalkTopic.OUTFIT, ...(raining ? [] : [TalkTopic.RAIN]), ...(sunsetAt < 0 ? [TalkTopic.SKY] : []), ...(posts.length < 2 ? [TalkTopic.FOLIAGE] : [])].filter((tp) => groupOf(tp).length)
|
||||
const taken = new Set([1, sunsetAt, ...bandAt.map(([at]) => at - 1)])
|
||||
const spreadAt = new Map<number, ReactNode>()
|
||||
let spreadN = 0
|
||||
for (let i = 0; i < posts.length && spreadN < spreadTopics.length; i++) {
|
||||
if (taken.has(i) || spreadAt.has(i - 1)) continue
|
||||
spreadAt.set(i, group(spreadTopics[spreadN++]))
|
||||
}
|
||||
const spreadLeft = spreadTopics.slice(spreadN).map((tp) => group(tp))
|
||||
|
||||
return (
|
||||
// 피드 칸은 전국 공통이라 지역이 바뀌어도 글 번호가 같다. 지역마다 새로 그려 넘긴 슬라이드·펼친 상태가 남지 않게 한다
|
||||
<section key={region.code} aria-label="오늘" aria-busy={load === 'loading'} className={cx('transition-opacity', feed.isPlaceholderData && 'opacity-60')}>
|
||||
@@ -631,6 +641,7 @@ export function TodayPage() {
|
||||
{mine.map((t) => (
|
||||
<TalkCard key={t.talk_id} t={t} onGone={() => setMine((m) => m.filter((x) => x.talk_id !== t.talk_id))} />
|
||||
))}
|
||||
{raining && group(TalkTopic.RAIN)}
|
||||
<MyGakRow />
|
||||
{/* 실패 안내는 여기 한 번만, 각 카드 스켈레톤과 같은 크기로 */}
|
||||
{stories.some((g) => g.active) ? (
|
||||
@@ -640,6 +651,7 @@ export function TodayPage() {
|
||||
) : (
|
||||
<StateBox load={load} onRetry={() => feed.refetch()} empty="오늘 계산된 각이 없어요." hold={<PostCardSkel />} className="inset-x-3 top-3 bottom-1" />
|
||||
)}
|
||||
<NearTalks talks={groupOf(0)} loaded={talkGroups.loaded} />
|
||||
<InstallBanner />
|
||||
<div>
|
||||
{load === 'loading' && <PostsSkel />}
|
||||
@@ -650,14 +662,16 @@ export function TodayPage() {
|
||||
{posts.map((p, i) => (
|
||||
<Fragment key={p.post_id}>
|
||||
<PostCard post={p} />
|
||||
{i === sunsetAt && group(TalkTopic.SKY)}
|
||||
{i === 1 && <FoliageCard post={f?.foliage_post} />}
|
||||
{i > 0 && i % TALK_EVERY === 0 && talks[i / TALK_EVERY - 1] && <TalkCard t={talks[i / TALK_EVERY - 1]} />}
|
||||
{i === 1 && group(TalkTopic.FOLIAGE)}
|
||||
{bandAt.find(([at]) => at === i + 1)?.[1]}
|
||||
{spreadAt.get(i)}
|
||||
</Fragment>
|
||||
))}
|
||||
{/* 글이 모자라 끼울 자리가 없던 묶음은 맨 뒤에 */}
|
||||
{feed.isSuccess && spreadLeft}
|
||||
{feed.isSuccess && bandAt.filter(([at]) => at > posts.length).map(([at, node]) => <Fragment key={at}>{node}</Fragment>)}
|
||||
{load !== 'loading' && talks.slice(between).map((t) => <TalkCard key={t.talk_id} t={t} />)}
|
||||
<div ref={moreRef} aria-hidden />
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
|
||||
+80
-9
@@ -1,5 +1,6 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { useEffect, useRef, useState, type ChangeEvent, type FormEvent } from 'react'
|
||||
import { Link } from 'react-router'
|
||||
import {
|
||||
addTalkMutation,
|
||||
blockTalkAuthorMutation,
|
||||
@@ -9,16 +10,16 @@ import {
|
||||
unlikeTalkMutation,
|
||||
} from '../api/client/@tanstack/react-query.gen'
|
||||
import { uploadTalkImage } from '../api/client/sdk.gen'
|
||||
import { TalkReport, type TalkData } from '../api/client/types.gen'
|
||||
import { TalkReport, TalkTopic, type TalkData } from '../api/client/types.gen'
|
||||
import { API_BASE_URL } from '../api/setup'
|
||||
import { cx } from '../lib/utils'
|
||||
import { useAuth } from './authContext'
|
||||
import { ago, kst } from './lib'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useMyTalks } from './talkState'
|
||||
import { topicName, TOPICS, useMyTalks } from './talkState'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { HeartIcon } from './svg'
|
||||
import { Avatar, TAP44 } from './ui'
|
||||
import { Avatar, Rail, TAP44 } from './ui'
|
||||
|
||||
const BODY_MAX = 100
|
||||
const PHOTO_MAX = 10 * 1024 * 1024
|
||||
@@ -30,6 +31,10 @@ const WRITE_ERRORS: Record<string, string> = {
|
||||
INVALID_INPUT: '100자 안으로 써 주세요.',
|
||||
}
|
||||
|
||||
// 글이 이보다 적으면 '동네 사람들' 묶음 대신 첫 글 쓰기 카드
|
||||
const GROUP_MIN = 3
|
||||
const COMPOSE_ID = 'talk-compose'
|
||||
|
||||
const REASONS = [
|
||||
[TalkReport.ABUSE, '욕설·비하'],
|
||||
[TalkReport.SPAM, '광고·도배'],
|
||||
@@ -45,7 +50,7 @@ function slotWord(iso: string) {
|
||||
|
||||
function useRefreshTalks() {
|
||||
const queryClient = useQueryClient()
|
||||
return () => queryClient.invalidateQueries({ predicate: (q) => ['listTalks', 'listMyTalks'].includes((q.queryKey[0] as { _id?: string } | undefined)?._id ?? '') })
|
||||
return () => queryClient.invalidateQueries({ predicate: (q) => ['listTalks', 'listMyTalks', 'talkGroups'].includes((q.queryKey[0] as { _id?: string } | undefined)?._id ?? '') })
|
||||
}
|
||||
|
||||
function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
|
||||
@@ -55,6 +60,7 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
|
||||
const refresh = useRefreshTalks()
|
||||
const add = useMutation(addTalkMutation())
|
||||
const [text, setText] = useState('')
|
||||
const [topic, setTopic] = useState<TalkTopic>(TalkTopic.LOCAL)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [photo, setPhoto] = useState<{ file: File; src: string } | null>(null)
|
||||
const [uploading, setUploading] = useState(false)
|
||||
@@ -97,12 +103,13 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
|
||||
upload().then(
|
||||
(image) =>
|
||||
add.mutate(
|
||||
{ body: { region_code: region.code, body, image } },
|
||||
{ body: { region_code: region.code, body, image, topic } },
|
||||
{
|
||||
onSuccess: (res) => {
|
||||
if (!res.result?.success) return setError(WRITE_ERRORS[res.result?.desc ?? ''] ?? '글을 올리지 못했어요. 다시 해 주세요.')
|
||||
setText('')
|
||||
setPhoto(null)
|
||||
setTopic(TalkTopic.LOCAL)
|
||||
refresh()
|
||||
if (res.talk) onDone?.(res.talk)
|
||||
},
|
||||
@@ -119,6 +126,7 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
|
||||
return (
|
||||
<form onSubmit={submit} className="mx-3 rounded-[22px] bg-white p-3 shadow-[inset_0_-5px_0_var(--shade)]">
|
||||
<textarea
|
||||
id={COMPOSE_ID}
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
onFocus={() => !loggedIn && open({ type: 'login' })}
|
||||
@@ -137,6 +145,20 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-2 flex flex-wrap gap-1.5" role="radiogroup" aria-label="글 주제">
|
||||
{TOPICS.map(([k, label]) => (
|
||||
<button
|
||||
key={k}
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={topic === k}
|
||||
onClick={() => setTopic(k)}
|
||||
className={cx('cursor-pointer rounded-full px-2.5 py-1 text-[12.5px] font-extrabold', topic === k ? 'bg-(--ink) text-white' : 'bg-[#f3f6fb] text-(--ink2)')}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<input ref={fileRef} type="file" accept="image/*" onChange={pick} hidden />
|
||||
<div className="mt-1.5 flex items-center gap-2 text-xs font-bold text-(--ink3)">
|
||||
<button type="button" onClick={() => (loggedIn ? fileRef.current?.click() : open({ type: 'login' }))} disabled={busy} className="shrink-0 cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1.5 text-[13px] font-extrabold text-(--ink2) disabled:opacity-40">
|
||||
@@ -160,7 +182,7 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
|
||||
}
|
||||
|
||||
/** onGone: 내 글을 지웠을 때. 목록을 다시 받아도 빠지지 않는 곳(방금 쓴 글)에서 직접 뺀다 */
|
||||
function TalkRow({ t, onGone }: { t: TalkData; onGone?: () => void }) {
|
||||
function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; compact?: boolean }) {
|
||||
const { loggedIn } = useAuth()
|
||||
const { open } = useSheet()
|
||||
const refresh = useRefreshTalks()
|
||||
@@ -205,6 +227,7 @@ function TalkRow({ t, onGone }: { t: TalkData; onGone?: () => void }) {
|
||||
onError: () => setFailed(true),
|
||||
}
|
||||
const guard = (run: () => void) => (loggedIn ? run() : open({ type: 'login' }))
|
||||
const src = t.image?.startsWith('/v1/') ? API_BASE_URL + t.image : (t.image ?? undefined)
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-[34px_1fr_24px] items-start gap-2.5 border-b border-(--line) py-2.5 last:border-b-0">
|
||||
@@ -212,10 +235,11 @@ function TalkRow({ t, onGone }: { t: TalkData; onGone?: () => void }) {
|
||||
<div className="min-w-0">
|
||||
<small className="block text-xs font-bold text-(--ink3)">
|
||||
<b className="mr-1 font-extrabold text-(--ink)">{t.nickname}</b>
|
||||
{[t.region_name, slotWord(t.created_at), t.weather].filter(Boolean).join(' · ')}
|
||||
{[t.region_name, slotWord(t.created_at), t.weather, t.topic && t.topic !== TalkTopic.LOCAL ? topicName(t.topic) : null].filter(Boolean).join(' · ')}
|
||||
</small>
|
||||
<p className="m-0 mt-0.5 text-[14.5px] break-words whitespace-pre-wrap">{t.body}</p>
|
||||
{t.image && <img src={t.image.startsWith('/v1/') ? API_BASE_URL + t.image : t.image} alt="" loading="lazy" className="mt-2 aspect-[4/5] w-full rounded-2xl bg-[#eef4fc] object-cover" />}
|
||||
{t.image && compact && <img src={src} alt="" loading="lazy" className="float-right mt-1 ml-2 size-12 rounded-xl bg-[#eef4fc] object-cover" />}
|
||||
<p className={cx('m-0 mt-0.5 text-[14.5px] break-words whitespace-pre-wrap', compact && 'line-clamp-2')}>{t.body}</p>
|
||||
{t.image && !compact && <img src={src} alt="" loading="lazy" className="mt-2 aspect-[4/5] w-full rounded-2xl bg-[#eef4fc] object-cover" />}
|
||||
<small className="mt-0.5 block text-xs font-bold text-(--ink3)">
|
||||
{ago(t.created_at)} · 좋아요 {count}개 ·{' '}
|
||||
<button type="button" onClick={() => setMenu(menu === 'closed' ? 'open' : 'closed')} aria-expanded={menu !== 'closed'} className="cursor-pointer font-bold text-(--ink3)">
|
||||
@@ -280,6 +304,53 @@ export function TalkCard({ t, onGone }: { t: TalkData; onGone?: () => void }) {
|
||||
)
|
||||
}
|
||||
|
||||
/** 오늘 피드의 사람 글 묶음: 옆으로 넘기는 카드, 끝에 그 주제 전체 보기 */
|
||||
export function TalkGroup({ title, topic, talks }: { title: string; topic?: number; talks: TalkData[] }) {
|
||||
return (
|
||||
<section aria-label={title} className="mt-3.5">
|
||||
<div className="flex items-end justify-between px-4">
|
||||
<h2 className="m-0 font-jua text-[19px] font-normal">{title}</h2>
|
||||
<Link to={topic ? `/talk?topic=${topic}` : '/talk'} className="text-[13px] font-bold text-(--ink2)">
|
||||
전체 보기
|
||||
</Link>
|
||||
</div>
|
||||
<Rail label={title}>
|
||||
{talks.map((t) => (
|
||||
<article key={`${t.talk_id}:${t.liked}:${t.like_count}`} className="w-[78%] max-w-[320px] rounded-[20px] bg-white px-3 shadow-[inset_0_-4px_0_var(--shade)]" aria-label={`${t.nickname}의 글`}>
|
||||
<TalkRow t={t} compact />
|
||||
</article>
|
||||
))}
|
||||
</Rail>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
/** '동네 사람들' 글이 적을 때 묶음 대신: 위 쓰기 칸으로 데려간다 */
|
||||
export function FirstTalkCard() {
|
||||
const { region } = useRegion()
|
||||
const place = region.name.split(' ').at(-1)
|
||||
const go = () => {
|
||||
const el = document.getElementById(COMPOSE_ID)
|
||||
el?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
el?.focus({ preventScroll: true })
|
||||
}
|
||||
return (
|
||||
<button type="button" onClick={go} className="mx-3 mt-3.5 flex w-[calc(100%-1.5rem)] cursor-pointer items-center gap-3 rounded-[22px] bg-white p-3.5 text-left shadow-[inset_0_-5px_0_var(--shade)]">
|
||||
<span className="font-jua text-[16.5px] leading-snug">
|
||||
지금 {place} 하늘 어때요?
|
||||
<small className="block font-sans text-[12.5px] font-semibold text-(--ink2)">첫 이야기를 남겨 주세요</small>
|
||||
</span>
|
||||
<span className="ml-auto shrink-0 rounded-full bg-(--orange) px-3.5 py-1.5 text-[13px] font-extrabold text-white">쓰기</span>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/** '동네 사람들' 자리: 글이 GROUP_MIN 개 이상이면 묶음, 아니면 첫 글 쓰기 */
|
||||
export function NearTalks({ talks, loaded }: { talks: TalkData[]; loaded: boolean }) {
|
||||
if (!loaded) return null
|
||||
return talks.length >= GROUP_MIN ? <TalkGroup title="동네 사람들" talks={talks} /> : <FirstTalkCard />
|
||||
}
|
||||
|
||||
/** 내 정보 창의 내가 쓴 글 */
|
||||
export function MyTalks() {
|
||||
const { talks, loaded, more, loadMore } = useMyTalks()
|
||||
|
||||
@@ -1,17 +1,37 @@
|
||||
import { useInfiniteQuery } from '@tanstack/react-query'
|
||||
import { listMyTalksInfiniteOptions, listTalksInfiniteOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
||||
import { listMyTalksInfiniteOptions, listTalksInfiniteOptions, talkGroupsOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import { TalkTopic, type TalkData } from '../api/client/types.gen'
|
||||
import { useRegion } from './regionContext'
|
||||
|
||||
/** 사람들이 쓴 글. 오늘 피드에 운영 포스트 사이사이 섞고, 남은 글은 피드 끝에 이어 붙인다 */
|
||||
export function useFeedTalks() {
|
||||
// 글 주제와 피드 묶음 이름
|
||||
export const TOPICS = [
|
||||
[TalkTopic.LOCAL, '동네 이야기'],
|
||||
[TalkTopic.SKY, '하늘·노을'],
|
||||
[TalkTopic.RAIN, '비·눈'],
|
||||
[TalkTopic.FOLIAGE, '단풍·꽃'],
|
||||
[TalkTopic.OUTFIT, '오늘 옷차림'],
|
||||
] as const
|
||||
export const topicName = (t?: number) => TOPICS.find(([k]) => k === t)?.[1] ?? '동네 이야기'
|
||||
|
||||
/** 오늘 피드 묶음: 0 은 '동네 사람들', 나머지는 주제별(3장 이상일 때만 옴) */
|
||||
export function useTalkGroups() {
|
||||
const { region } = useRegion()
|
||||
const q = useQuery(talkGroupsOptions({ query: { region: region.code } }))
|
||||
const groups = new Map<number, TalkData[]>((q.data?.groups ?? []).map((g) => [g.topic, g.talks ?? []]))
|
||||
return { groups, loaded: q.isSuccess }
|
||||
}
|
||||
|
||||
/** 주제별 글 페이지 목록 (topic 없으면 전체) */
|
||||
export function useTopicTalks(topic?: TalkTopic) {
|
||||
const { region } = useRegion()
|
||||
const list = useInfiniteQuery({
|
||||
...listTalksInfiniteOptions({ query: { region: region.code } }),
|
||||
...listTalksInfiniteOptions({ query: { region: region.code, ...(topic ? { topic } : {}) } }),
|
||||
initialPageParam: {},
|
||||
getNextPageParam: (last) => last.next_cursor ?? undefined,
|
||||
})
|
||||
return {
|
||||
talks: list.data?.pages.flatMap((p) => p.talks ?? []) ?? [],
|
||||
loaded: list.isSuccess,
|
||||
more: list.hasNextPage && !list.isFetchingNextPage,
|
||||
loadMore: list.fetchNextPage,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user