Update: [main] 디스코드 알림 개선 - footer 제거 및 워크북 진행도 표시
All checks were successful
baekjoon-bot-cicd / build_push_deploy (push) Successful in 5m40s
All checks were successful
baekjoon-bot-cicd / build_push_deploy (push) Successful in 5m40s
워크북 모드에서 (k/n) 진행도를 타이틀에 표시하고, 양쪽 모드 모두 하단 정기 알림 footer 제거 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
7
app.py
7
app.py
@@ -86,7 +86,7 @@ async def today(
|
||||
if not wid:
|
||||
return JSONResponse(status_code=400, content={"error": "workbook_id is required for workbook mode"})
|
||||
|
||||
pid, title, level = await pick_from_workbook(db, wid, pick=workbook_pick)
|
||||
pid, title, level, current_idx, total_cnt = await pick_from_workbook(db, wid, pick=workbook_pick)
|
||||
if not pid:
|
||||
return JSONResponse(status_code=409, content={"error": "no_more_problems_in_workbook", "workbook_id": wid})
|
||||
|
||||
@@ -94,9 +94,10 @@ async def today(
|
||||
solved_url = f"https://solved.ac/problems/id/{pid}"
|
||||
level_text = f"Lv. {level}" if level is not None else "Lv. ?"
|
||||
|
||||
progress_text = f"({current_idx}/{total_cnt})" if current_idx and total_cnt else ""
|
||||
discord_payload = {
|
||||
"embeds": [{
|
||||
"title": "🔔 오늘의 백준 추천 문제 (문제집)",
|
||||
"title": f"🔔 오늘의 백준 추천 문제 (문제집) {progress_text}",
|
||||
"description": (
|
||||
f"**{pid}번: {title}**\n"
|
||||
f"난이도: **{level_text}**\n"
|
||||
@@ -106,7 +107,6 @@ async def today(
|
||||
{"name": "문제 링크", "value": f"[바로가기]({problem_url})", "inline": True},
|
||||
{"name": "해설/정보", "value": f"[Solved.ac]({solved_url})", "inline": True},
|
||||
],
|
||||
"footer": {"text": "매일 오전 10시 정기 알림 (n8n)"}
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -155,7 +155,6 @@ async def today(
|
||||
{"name": "문제 링크", "value": f"[바로가기]({problem_url})", "inline": True},
|
||||
{"name": "해설/정보", "value": f"[Solved.ac]({solved_url})", "inline": True},
|
||||
],
|
||||
"footer": {"text": "매일 오전 10시 정기 알림 (n8n)"}
|
||||
}]
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ async def pick_from_workbook(
|
||||
db: AsyncSession,
|
||||
workbook_id: int,
|
||||
pick: str = "random", # random | level_asc
|
||||
) -> Tuple[Optional[int], Optional[str], Optional[int]]:
|
||||
) -> Tuple[Optional[int], Optional[str], Optional[int], Optional[int], Optional[int]]:
|
||||
"""
|
||||
workbook_id에서 아직 보내지 않은 문제 1개 선택 + workbook_sends 기록까지 원샷.
|
||||
pick:
|
||||
@@ -46,17 +46,27 @@ async def pick_from_workbook(
|
||||
FROM candidate
|
||||
ON CONFLICT DO NOTHING
|
||||
RETURNING problem_id
|
||||
),
|
||||
total AS (
|
||||
SELECT COUNT(*) AS cnt FROM workbook_problems WHERE workbook_id = :wid
|
||||
),
|
||||
sent AS (
|
||||
SELECT COUNT(*) AS cnt FROM workbook_sends WHERE workbook_id = :wid
|
||||
)
|
||||
SELECT problem_id, title, level
|
||||
SELECT candidate.problem_id, candidate.title, candidate.level,
|
||||
(SELECT cnt FROM sent) + 1 AS current_idx,
|
||||
(SELECT cnt FROM total) AS total_cnt
|
||||
FROM candidate;
|
||||
"""
|
||||
|
||||
row = (await db.execute(text(sql), {"wid": workbook_id})).first()
|
||||
if not row:
|
||||
return None, None, None
|
||||
return None, None, None, None, None
|
||||
|
||||
await db.commit()
|
||||
pid = int(row[0])
|
||||
title = str(row[1])
|
||||
level = int(row[2]) if row[2] is not None else None
|
||||
return pid, title, level
|
||||
current_idx = int(row[3])
|
||||
total_cnt = int(row[4])
|
||||
return pid, title, level, current_idx, total_cnt
|
||||
|
||||
Reference in New Issue
Block a user