@@ -80,6 +80,7 @@ async def _get_problem_data(self, problem_slug: str) -> Dict[str, str]:
80
80
query = """
81
81
query getQuestionDetail($titleSlug: String!) {
82
82
question(titleSlug: $titleSlug) {
83
+ frequency
83
84
questionId
84
85
questionFrontendId
85
86
boundTopicId
@@ -233,22 +234,28 @@ def get_leetcode_api_client() -> leetcode.DefaultApi:
233
234
return api_instance
234
235
235
236
236
- def get_leetcode_task_handles () -> Iterator [Tuple [str , str , str ]]:
237
+ def get_leetcode_task_handles () -> Iterator [Tuple [str , str , str , str ]]:
237
238
api_instance = get_leetcode_api_client ()
238
239
239
240
for topic in ["algorithms" , "database" , "shell" , "concurrency" ]:
240
241
api_response = api_instance .api_problems_topic_get (topic = topic )
241
242
for stat_status_pair in api_response .stat_status_pairs :
242
243
stat = stat_status_pair .stat
243
244
244
- yield (topic , stat .question__title , stat .question__title_slug )
245
+ yield (
246
+ topic ,
247
+ stat .question__title ,
248
+ stat .question__title_slug ,
249
+ stat_status_pair .frequency ,
250
+ )
245
251
246
252
247
253
async def generate_anki_note (
248
254
leetcode_data : LeetcodeData ,
249
255
leetcode_model : genanki .Model ,
250
256
leetcode_task_handle : str ,
251
257
leetcode_task_title : str ,
258
+ leetcode_task_frequency : str ,
252
259
topic : str ,
253
260
) -> LeetcodeNote :
254
261
return LeetcodeNote (
@@ -272,6 +279,7 @@ async def generate_anki_note(
272
279
* 100
273
280
)
274
281
),
282
+ str (leetcode_task_frequency ),
275
283
],
276
284
tags = await leetcode_data .tags (leetcode_task_handle ),
277
285
)
@@ -294,6 +302,7 @@ async def generate(start: int, stop: int) -> None:
294
302
{"name" : "SubmissionsTotal" },
295
303
{"name" : "SubmissionsAccepted" },
296
304
{"name" : "SumissionAcceptRate" },
305
+ {"name" : "Frequency" },
297
306
# TODO: add hints
298
307
],
299
308
templates = [
@@ -308,6 +317,11 @@ async def generate(start: int, stop: int) -> None:
308
317
({{SumissionAcceptRate}}%)
309
318
<br/>
310
319
<b>Topic:</b> {{Topic}}<br/>
320
+ <b>Frequency:</b>
321
+ <progress value="{{Frequency}}" max="100">
322
+ {{Frequency}}%
323
+ </progress>
324
+ <br/>
311
325
<b>URL:</b>
312
326
<a href='https://leetcode.com/problems/{{Slug}}/'>
313
327
https://leetcode.com/problems/{{Slug}}/
@@ -338,15 +352,19 @@ async def generate(start: int, stop: int) -> None:
338
352
339
353
note_generators : List [Coroutine [Any , Any , LeetcodeNote ]] = []
340
354
341
- for topic , leetcode_task_title , leetcode_task_handle in list (
342
- get_leetcode_task_handles ()
343
- )[start :stop ]:
355
+ for (
356
+ topic ,
357
+ leetcode_task_title ,
358
+ leetcode_task_handle ,
359
+ leetcode_task_frequency ,
360
+ ) in list (get_leetcode_task_handles ())[start :stop ]:
344
361
note_generators .append (
345
362
generate_anki_note (
346
363
leetcode_data ,
347
364
leetcode_model ,
348
365
leetcode_task_handle ,
349
366
leetcode_task_title ,
367
+ leetcode_task_frequency ,
350
368
topic ,
351
369
)
352
370
)
0 commit comments