feat(snippets): 한글 설명 초안 143개·새 이름 11개 검토 파일 + import_snippets 는 빈 DB 에서만(규칙 변경 후 중복·옛 이름 부활 방지)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7a1498a791
commit
f0520cdcc1
@@ -1,6 +1,10 @@
|
||||
"""옛 로컬 snippets.db(SQLite) → 서버. 같은 이름은 건너뜀(--overwrite 로 덮어씀).
|
||||
"""옛 로컬 snippets.db(SQLite) → 서버. **스니펫이 하나도 없을 때만**(처음 채우기). --force 면 비어 있지 않아도.
|
||||
|
||||
python manage.py import_snippets ../CODE_ASSISTANT_DB/snippets.db
|
||||
|
||||
deploy.sh 가 배포 때마다 부르므로, 이미 채워진 DB 에서 다시 돌면 안 됨 —
|
||||
2026-09-23: 이름 규칙이 바뀐 뒤 다시 돌면 옛 이름(IF_SUBRC-ABAP)이 새 규칙 이름(IF_SUBRC_ABAP)으로 중복 추가되고,
|
||||
apply_snippet_meta 로 이름을 바꾼 뒤엔 옛 이름이 되살아났음. 이름은 옛 규칙 그대로 둠(lookup_name).
|
||||
"""
|
||||
|
||||
import sqlite3
|
||||
@@ -8,7 +12,7 @@ import sqlite3
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from apps.snippets.models import Snippet
|
||||
from apps.snippets.views import normalize_name
|
||||
from apps.snippets.views import lookup_name
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -17,13 +21,17 @@ class Command(BaseCommand):
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("path")
|
||||
parser.add_argument("--overwrite", action="store_true")
|
||||
parser.add_argument("--force", action="store_true", help="스니펫이 이미 있어도 가져옴")
|
||||
|
||||
def handle(self, path, overwrite, **_):
|
||||
def handle(self, path, overwrite, force, **_):
|
||||
if Snippet.objects.exists() and not force:
|
||||
self.stdout.write(f"이미 스니펫 {Snippet.objects.count()}개 있음 — 건너뜀(처음 채울 때만 씀, 필요하면 --force)")
|
||||
return
|
||||
con = sqlite3.connect(path)
|
||||
rows = con.execute("SELECT name, desc, body, category FROM snippets").fetchall()
|
||||
added = updated = skipped = 0
|
||||
for name, desc, body, category in rows:
|
||||
name = normalize_name(name)
|
||||
name = lookup_name(name)
|
||||
if not name or not (body or "").strip():
|
||||
skipped += 1
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user