여러 줄 주석이 설명보다 경위(예전·실측·지적)를 적고 있어 읽는 사람이 결론을 찾기 어려웠다. - ts·tsx·js·mjs·css·py 478개: 여러 줄 주석은 첫 문장 한 줄로, 과거형·날짜 문장은 삭제 - 주석 위치는 TypeScript 파서·파이썬 tokenize/ast 로 찾는다 — 문자열 안의 # · /* 는 건드리지 않는다 - eslint·ts·noqa·type: ignore 같은 지시 주석은 그대로 둔다 파이썬 275개 정리 전후 AST 동일, TS 298개 주석 뺀 토큰 동일(빈 JSX 주석 10곳만 차이). site·frontend·admin tsc, site vitest 105 passed Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""site_sections — **개인화 데이터**의 단일 자리."""
|
|
from sqlalchemy import select
|
|
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
|
|
|
from common.database.db_session_manager import DB_SESSION_MNG
|
|
from common.database.model.models import site_sections
|
|
from common.utils.gtime import GTime
|
|
|
|
|
|
class SiteSectionCRUD:
|
|
async def list_by_site(self, db, site_id):
|
|
return await DB_SESSION_MNG.execute(
|
|
db,
|
|
select(site_sections).where(
|
|
site_sections.site_id == site_id,
|
|
site_sections.deleted == False, # noqa: E712
|
|
).order_by(site_sections.sort_order.asc()),
|
|
)
|
|
|
|
async def upsert(self, db, values: dict):
|
|
"""섹션 하나의 개인화 값을 넣거나 갱신한다."""
|
|
stmt = pg_insert(site_sections).values(**values)
|
|
return await DB_SESSION_MNG.add(
|
|
db,
|
|
stmt.on_conflict_do_update(
|
|
index_elements=[site_sections.site_id, site_sections.section_id],
|
|
index_where=(site_sections.deleted == False), # noqa: E712
|
|
set_={
|
|
"data": stmt.excluded.data,
|
|
"shared_ref": stmt.excluded.shared_ref,
|
|
"updated_at": GTime.UTC(),
|
|
},
|
|
),
|
|
)
|