Skip to content

Commit a740d0a

Browse files
committed
going back
1 parent dcde17a commit a740d0a

9 files changed

Lines changed: 21 additions & 209 deletions

File tree

‎lua/leetcode-ui/group/page/blind-75.lua‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ local list = Button("List", {
2121
on_press = cmd.blind_75
2222
})
2323

24-
local grouped = Button("Grouped", {
25-
icon = "󰕘",
26-
sc = "g",
27-
on_press = cmd.blind_75_grouped,
28-
})
29-
3024
local random = Button("Random", {
3125
icon = "",
3226
sc = "r",
@@ -37,7 +31,6 @@ local back = BackButton("problems")
3731

3832
page:insert(Buttons({
3933
list,
40-
grouped,
4134
random,
4235
back,
4336
}))

‎lua/leetcode-ui/group/page/leetcode-75.lua‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ local list = Button("List", {
2121
on_press = cmd.leetcode_75
2222
})
2323

24-
local grouped = Button("Grouped", {
25-
icon = "󰕘",
26-
sc = "g",
27-
on_press = cmd.leetcode_75_grouped,
28-
})
29-
3024
local random = Button("Random", {
3125
icon = "",
3226
sc = "r",
@@ -37,7 +31,6 @@ local back = BackButton("problems")
3731

3832
page:insert(Buttons({
3933
list,
40-
grouped,
4134
random,
4235
back
4336
}))

‎lua/leetcode-ui/group/page/top-150.lua‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ local list = Button("List", {
2121
on_press = cmd.top_interview_150
2222
})
2323

24-
local grouped = Button("Grouped", {
25-
icon = "󰕘",
26-
sc = "g",
27-
on_press = cmd.top_interview_150_grouped,
28-
})
29-
3024
local random = Button("Random", {
3125
icon = "",
3226
sc = "r",
@@ -37,7 +31,6 @@ local back = BackButton("problems")
3731

3832
page:insert(Buttons({
3933
list,
40-
grouped,
4134
random,
4235
back
4336
}))

‎lua/leetcode/api/queries.lua‎

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -180,29 +180,16 @@ queries.session_progress = [[
180180
]]
181181

182182
queries.study_plan_detail = [[
183-
query studyPlanDetail($slug: String!) {
184-
studyPlanV2Detail(planSlug: $slug) {
185-
planSubGroups {
186-
questions {
187-
title_slug: titleSlug
188-
difficulty
189-
id
190-
paidOnly
191-
questionFrontendId
192-
status
193-
title
194-
translatedTitle
195-
acRate
196-
topicTags {
197-
name
198-
nameTranslated
199-
slug
183+
query studyPlanDetail($slug: String!) {
184+
studyPlanV2Detail(planSlug: $slug) {
185+
planSubGroups {
186+
questions {
187+
title_slug: titleSlug
200188
}
201189
}
202190
}
203191
}
204-
}
205-
]]
192+
]]
206193

207194
queries.problem_list_detail = [[
208195
query favoriteQuestionList($favoriteSlug: String!, $filter: FavoriteQuestionFilterInput, $filtersV2: QuestionFilterInput, $searchKeyword: String, $sortBy: QuestionSortByInput, $limit: Int, $skip: Int, $version: String) {

‎lua/leetcode/command/init.lua‎

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -186,77 +186,6 @@ function cmd.top_interview_150()
186186
end)
187187
end
188188

189-
function cmd.blind_75_grouped()
190-
require("leetcode.utils").auth_guard()
191-
local problems = require("leetcode.api.problems")
192-
problems.blind_75(function(slugs, err)
193-
if err then
194-
return log.err(err)
195-
end
196-
local p = require("leetcode.cache.problemlist").get_by_title_slugs(slugs)
197-
local picker = require("leetcode.picker")
198-
picker.question(p, nil, true)
199-
end)
200-
end
201-
202-
function cmd.leetcode_75_grouped()
203-
require("leetcode.utils").auth_guard()
204-
local problems = require("leetcode.api.problems")
205-
problems.leetcode_75(function(slugs, err)
206-
if err then
207-
return log.err(err)
208-
end
209-
local p = require("leetcode.cache.problemlist").get_by_title_slugs(slugs)
210-
local picker = require("leetcode.picker")
211-
picker.question(p, nil, true)
212-
end)
213-
end
214-
215-
function cmd.top_interview_150_grouped()
216-
require("leetcode.utils").auth_guard()
217-
local problems = require("leetcode.api.problems")
218-
problems.top_interview_150(function(slugs, err)
219-
if err then
220-
return log.err(err)
221-
end
222-
local p = require("leetcode.cache.problemlist").get_by_title_slugs(slugs)
223-
local picker = require("leetcode.picker")
224-
picker.question(p, nil, true)
225-
end)
226-
end
227-
228-
function cmd.debug_blind_75_structure()
229-
require("leetcode.utils").auth_guard()
230-
local problems = require("leetcode.api.problems")
231-
problems.blind_75(function(slugs, err)
232-
if err then
233-
return log.err(err)
234-
end
235-
236-
local p = require("leetcode.cache.problemlist").get_by_title_slugs(slugs)
237-
238-
if p and #p > 0 then
239-
local first_question = p[1]
240-
print("Structure de la première question:")
241-
print(vim.inspect(first_question))
242-
243-
if first_question.topic_tags then
244-
print("topic_tags trouvés:", vim.inspect(first_question.topic_tags))
245-
elseif first_question.topicTags then
246-
print("topicTags trouvés:", vim.inspect(first_question.topicTags))
247-
else
248-
print("Aucun tag trouvé dans cette structure")
249-
250-
local problemlist = require("leetcode.cache.problemlist")
251-
local full_question = problemlist.get_by_title_slug(first_question.title_slug)
252-
if full_question then
253-
print("Question complète du cache:", vim.inspect(full_question))
254-
end
255-
end
256-
end
257-
end)
258-
end
259-
260189
function cmd.random_question(opts)
261190
require("leetcode.utils").auth_guard()
262191

‎lua/leetcode/picker/question/fzf.lua‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ local Picker = require("leetcode.picker")
66

77
local deli = " "
88

9-
return function(questions, opts, group_by_category)
10-
local items = question_picker.items(questions, opts, group_by_category)
9+
return function(questions, opts)
10+
local items = question_picker.items(questions, opts)
1111

1212
for i, item in ipairs(items) do
1313
items[i] = Picker.normalize({ item })[1]
@@ -16,7 +16,7 @@ return function(questions, opts, group_by_category)
1616
end
1717

1818
fzf.fzf_exec(items, {
19-
prompt = t("Select a Question") .. (group_by_category and " (Grouped)" or "") .. "> ",
19+
prompt = t("Select a Question") .. "> ",
2020
winopts = {
2121
height = question_picker.height,
2222
width = question_picker.width,
@@ -28,9 +28,6 @@ return function(questions, opts, group_by_category)
2828
actions = {
2929
["default"] = function(selected)
3030
local slug = Picker.hidden_field(selected[1], deli)
31-
if slug:match("^__category_") then
32-
return
33-
end
3431
local question = problemlist.get_by_title_slug(slug)
3532
question_picker.select(question)
3633
end,

‎lua/leetcode/picker/question/init.lua‎

Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -36,71 +36,15 @@ function P.filter(items, opts)
3636
end, items)
3737
end
3838

39-
---@param items lc.cache.Question[]
40-
---@param group_by_category boolean
41-
---@return lc.cache.Question[]
42-
function P.group_by_category(items, group_by_category)
43-
if not group_by_category then
44-
return items
45-
end
46-
47-
local categories = {}
48-
for _, question in ipairs(items) do
49-
local tags = question.tags or question.topic_tags or {}
50-
if #tags == 0 then
51-
table.insert(categories, { category = "Other", questions = { question } })
52-
else
53-
for _, tag in ipairs(tags) do
54-
local category_name = tag.name or tag
55-
local found = false
56-
for _, cat in ipairs(categories) do
57-
if cat.category == category_name then
58-
table.insert(cat.questions, question)
59-
found = true
60-
break
61-
end
62-
end
63-
if not found then
64-
table.insert(categories, { category = category_name, questions = { question } })
65-
end
66-
end
67-
end
68-
end
69-
70-
table.sort(categories, function(a, b) return a.category < b.category end)
71-
72-
local result = {}
73-
for _, cat in ipairs(categories) do
74-
table.insert(result, {
75-
frontend_id = "---",
76-
title = "─── " .. cat.category:upper() .. " ───",
77-
title_slug = "__category_" .. cat.category,
78-
difficulty = "",
79-
status = "category_header",
80-
ac_rate = 0,
81-
paid_only = false,
82-
is_category_header = true,
83-
})
84-
85-
for _, question in ipairs(cat.questions) do
86-
table.insert(result, question)
87-
end
88-
end
89-
90-
return result
91-
end
92-
9339
---@param content lc.cache.Question[]
9440
---@param opts table<string, string[]>
95-
---@param group_by_category boolean|nil
41+
---
9642
---@return { entry: any, value: lc.cache.Question }[]
97-
function P.items(content, opts, group_by_category)
43+
function P.items(content, opts)
9844
local filtered = P.filter(content, opts)
99-
local grouped = P.group_by_category(filtered, group_by_category)
100-
10145
return vim.tbl_map(function(item)
10246
return { entry = P.entry(item), value = item }
103-
end, grouped)
47+
end, filtered)
10448
end
10549

10650
---@param question lc.cache.Question
@@ -128,14 +72,6 @@ local function display_question(question)
12872
end
12973

13074
function P.entry(item)
131-
if item.is_category_header then
132-
return {
133-
{ "", "leetcode_normal" },
134-
{ "", "leetcode_normal" },
135-
{ item.title, "leetcode_list" },
136-
}
137-
end
138-
13975
return {
14076
display_user_status(item),
14177
display_difficulty(item),
@@ -154,10 +90,6 @@ function P.ordinal(item)
15490
end
15591

15692
function P.select(selection, close)
157-
if selection.is_category_header then
158-
return
159-
end
160-
16193
if selection.paid_only and not config.auth.is_premium then
16294
return log.warn("Question is for premium users only")
16395
end

‎lua/leetcode/picker/question/snacks.lua‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ local question_picker = require("leetcode.picker.question")
55
local picker = require("snacks.picker")
66

77
---@param questions lc.cache.Question[]
8-
return function(questions, opts, group_by_category)
9-
local items = question_picker.items(questions, opts, group_by_category)
8+
return function(questions, opts)
9+
local items = question_picker.items(questions, opts)
1010
local finder_items = {}
1111
local completed = false
1212

@@ -32,7 +32,7 @@ return function(questions, opts, group_by_category)
3232
end, item.item.entry)
3333
return ret
3434
end,
35-
title = t("Select a Question") .. (group_by_category and " (Grouped)" or ""),
35+
title = t("Select a Question"),
3636
layout = {
3737
preset = "select",
3838
preview = false,
@@ -43,7 +43,7 @@ return function(questions, opts, group_by_category)
4343
},
4444
actions = {
4545
confirm = function(p, item)
46-
if completed or item.item.value.is_category_header then
46+
if completed then
4747
return
4848
end
4949
completed = true

‎lua/leetcode/picker/question/telescope.lua‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,12 @@ local theme = require("telescope.themes").get_dropdown({
4242
})
4343

4444
---@param questions lc.cache.Question[]
45-
return function(questions, opts, group_by_category)
46-
local items = question_picker.items(questions, opts, group_by_category)
47-
48-
local function entry_maker(item)
49-
return {
50-
value = item.value,
51-
display = function()
52-
return displayer(item.entry)
53-
end,
54-
ordinal = item.value.is_category_header and item.value.title or question_picker.ordinal(item.value),
55-
}
56-
end
45+
return function(questions, opts)
46+
local items = question_picker.items(questions, opts)
5747

5848
pickers
5949
.new(theme, {
60-
prompt_title = t("Select a Question") .. (group_by_category and " (Grouped)" or ""),
50+
prompt_title = t("Select a Question"),
6151
finder = finders.new_table({
6252
results = items,
6353
entry_maker = entry_maker,
@@ -66,10 +56,8 @@ return function(questions, opts, group_by_category)
6656
attach_mappings = function(prompt_bufnr)
6757
actions.select_default:replace(function()
6858
local selection = action_state.get_selected_entry()
69-
if not selection or selection.value.is_category_header then
70-
if not selection then
71-
log.warn("No selection")
72-
end
59+
if not selection then
60+
log.warn("No selection")
7361
return
7462
end
7563
question_picker.select(selection.value, function()

0 commit comments

Comments
 (0)