88
99CHALLENGE_TYPES = {
1010 "๊ทธ๋ํ" : 5 ,
11- "DP " : 5
11+ "๊ตฌํ " : 5
1212}
1313
1414def generate_dashboard (scoreboard ):
@@ -38,24 +38,37 @@ def generate_dashboard(scoreboard):
3838 md += "\n \n "
3939 return md
4040
41- def archive_current_month (scoreboard ):
42- # HISTORY_FILE์ ํ์ฌ ๋ฌ ๊ธฐ๋ก์ ์ถ๊ฐ (append ๋ฐฉ์)
43- dashboard_md = generate_dashboard (scoreboard )
41+ def archive_current_month ():
42+ """
43+ HISTORY_FILE์ ํ์ฌ ๋ฌ ๊ธฐ๋ก์ ์ถ๊ฐ (append ๋ฐฉ์)
44+ """
45+ # 1. DASHBOARD.md ์ฝ๊ธฐ
46+ try :
47+ with open (DASHBOARD_FILE , "r" , encoding = "utf-8" ) as db :
48+ dashboard_md = db .read ()
49+ except FileNotFoundError :
50+ print ("[Archive] DASHBOARD.md not found. Please create DASHBOARD.md first." )
51+ return
52+
53+ # 2. HISTORY.md์ append
4454 with open (HISTORY_FILE , "a" , encoding = "utf-8" ) as f :
4555 f .write (dashboard_md )
46- f .write ("\n \n " ) # ๊ตฌ๋ถ์ ์ํ ๋น ์ค ์ถ๊ฐ
47- print ("HISTORY.md ์
๋ฐ์ดํธ ์๋ฃ! " )
56+ f .write ("\n \n " ) # ๊ตฌ๋ถ์ฉ ๋น ์ค
57+ print ("[Archive] Appended current dashboard to HISTORY.md successfully. " )
4858
4959def update_dashboard ():
5060 # 1. scoreboard.json ๋ก๋
61+ print ("[Step 1] Loading scoreboard file..." )
5162 if not os .path .exists (SCOREBOARD_FILE ):
52- print (f"{ SCOREBOARD_FILE } ํ์ผ์ด ์์ต๋๋ค. " )
63+ print (f"[Step 1] File not found: { SCOREBOARD_FILE } " )
5364 return
5465
5566 with open (SCOREBOARD_FILE , "r" , encoding = "utf-8" ) as f :
5667 scoreboard = json .load (f )
68+ print ("[Step 1] Loaded scoreboard data." )
5769
5870 # 2. ๊ธฐ์กด ํ์ผ ๊ตฌ์กฐ๊ฐ ์ ํ์("month", "users")์ด ์๋๋ผ๋ฉด ๋ณํ
71+ print ("[Step 2] Verifying scoreboard structure..." )
5972 if "month" not in scoreboard or "users" not in scoreboard :
6073 # ๊ธฐ์กด ๊ตฌ์กฐ๋ ์ฌ์ฉ์ ์ด๋ฆ์ด ์ต์์ ํค์ธ ํํ
6174 scoreboard = {
@@ -65,30 +78,15 @@ def update_dashboard():
6578 # ์ ํ์์ผ๋ก ์ ์ฅ
6679 with open (SCOREBOARD_FILE , "w" , encoding = "utf-8" ) as f :
6780 json .dump (scoreboard , f , ensure_ascii = False , indent = 2 )
68- print ("๊ธฐ์กด scoreboard ํ์์ ์ ๊ตฌ์กฐ๋ก ๋ณํํ์์ต๋๋ค." )
69-
70- # 3. ํ์ฌ ๋ฌ ํ์ธ ๋ฐ ์ ์ด๊ธฐํ ์ฒ๋ฆฌ
71- current_month = datetime .now ().strftime ("%Y-%m" )
72- stored_month = scoreboard .get ("month" , current_month )
73- print (f"ํ์ฌ ๋ฌ: { current_month } , ์ ์ฅ๋ ๋ฌ: { stored_month } " )
74-
75- if stored_month != current_month :
76- print (f"์๋ก์ด ๋ฌ({ current_month } )๋ก ๋์ด๊ฐ - ์ด์ ๋ฌ({ stored_month } ) ๊ธฐ๋ก์ ํ์คํ ๋ฆฌ์ ์ ์ฅํฉ๋๋ค." )
77- archive_current_month (scoreboard )
78- # scoreboard ์ด๊ธฐํ: users๋ ๋น dict, month๋ ํ์ฌ ๋ฌ๋ก ๊ฐฑ์
79- scoreboard = {
80- "month" : current_month ,
81- "users" : {}
82- }
83- with open (SCOREBOARD_FILE , "w" , encoding = "utf-8" ) as f :
84- json .dump (scoreboard , f , ensure_ascii = False , indent = 2 )
81+ print ("[Step 2] Converted existing scoreboard format to new structure." )
8582
86- # 4. DASHBOARD.md ํ์ผ ์์ฑ ๋ฐ ์
๋ฐ์ดํธ
83+ # 3. DASHBOARD.md ํ์ผ ์์ฑ ๋ฐ ์
๋ฐ์ดํธ
84+ print ("[Step 3] Generating dashboard content..." )
8785 md_content = generate_dashboard (scoreboard )
8886 with open (DASHBOARD_FILE , "w" , encoding = "utf-8" ) as f :
8987 f .write (md_content )
9088
91- print ("DASHBOARD.md ์
๋ฐ์ดํธ ์๋ฃ! " )
89+ print ("[Step 3] DASHBOARD.md updated successfully. " )
9290
9391if __name__ == '__main__' :
9492 update_dashboard ()
0 commit comments