MCPcopy Create free account
hub / github.com/acm-clan/algorithm-stone / update_db

Method update_db

src/leetcode.py:167–192  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

165 self.dict["leetcode_update_db_time"] = util.now()
166
167 def update_db(self):
168 t = self.get_update_db_time()
169 if util.now()-t < 24*3600*1000:
170 return
171
172 url = withUrl("api/problems/all/")
173 f = urllib.request.urlopen(url)
174 content = f.read().decode('utf-8')
175 qlist = json.loads(content)
176
177 try:
178 for q in qlist['stat_status_pairs']:
179 id = q['stat']['question_id']
180 front_id = q['stat']['frontend_question_id']
181 if is_int(front_id):
182 id = int(front_id)
183 level = q['difficulty']['level']
184 slug = q['stat']['question__title_slug']
185 paid_only = q['paid_only']
186 title = self.get_title_with_slug(id, slug, paid_only)
187 print("id:", id, level, title)
188
189 self.save_update_db_time()
190 except Exception as e:
191 print("leetcode update db error:", e)
192 pass

Callers 1

processFunction · 0.95

Calls 6

get_update_db_timeMethod · 0.95
get_title_with_slugMethod · 0.95
save_update_db_timeMethod · 0.95
withUrlFunction · 0.85
printFunction · 0.85
is_intFunction · 0.70

Tested by

no test coverage detected