@@ -26,6 +26,7 @@ def _create_default(self):
2626 "medium" : 0 ,
2727 "hard" : 0 ,
2828 "languages" : {},
29+ "recent_problems" : [],
2930 "last_problem" : None ,
3031 "last_sync" : None ,
3132 }
@@ -61,7 +62,7 @@ def save(self, stats):
6162
6263 def update (self , profile , detail ):
6364 """
64- Update statistics using latest profile and submission .
65+ Update repository statistics .
6566 """
6667
6768 stats = self .load ()
@@ -76,6 +77,7 @@ def update(self, profile, detail):
7677 stats ["medium" ] = solved .get ("Medium" , 0 )
7778 stats ["hard" ] = solved .get ("Hard" , 0 )
7879
80+
7981 language = detail .language_verbose
8082
8183 languages = stats .get ("languages" , {})
@@ -86,15 +88,36 @@ def update(self, profile, detail):
8688
8789 stats ["languages" ] = languages
8890
89- stats ["last_problem" ] = {
91+
92+ latest = {
9093 "id" : detail .question_id ,
9194 "title" : detail .title_slug .replace ("-" , " " ).title (),
9295 "language" : detail .language_verbose ,
9396 "runtime" : detail .runtime_display ,
9497 "memory" : detail .memory_display ,
9598 }
9699
97- stats ["last_sync" ] = datetime .now ().isoformat ()
100+ stats ["last_problem" ] = latest
101+
102+
103+ recent = stats .get ("recent_problems" , [])
104+
105+ recent .insert (
106+ 0 ,
107+ {
108+ "id" : detail .question_id ,
109+ "title" : detail .title_slug .replace ("-" , " " ).title (),
110+ },
111+ )
112+
113+
114+ stats ["recent_problems" ] = recent [:5 ]
115+
116+ # ---------- Last sync ----------
117+
118+ stats ["last_sync" ] = datetime .now ().strftime (
119+ "%Y-%m-%d %H:%M:%S"
120+ )
98121
99122 self .save (stats )
100123
0 commit comments