fix: remove unused function
This commit is contained in:
parent
2809689494
commit
057b0890c2
3 changed files with 23 additions and 48 deletions
|
|
@ -4,6 +4,18 @@
|
|||
---@field problem_id? string
|
||||
---@field language? string
|
||||
|
||||
---@class ContestData
|
||||
---@field problems Problem[]
|
||||
---@field test_cases? CachedTestCase[]
|
||||
---@field timeout_ms? number
|
||||
---@field memory_mb? number
|
||||
---@field interactive? boolean
|
||||
|
||||
---@class ContestSummary
|
||||
---@field display_name string
|
||||
---@field name string
|
||||
---@field id string
|
||||
|
||||
---@class CacheData
|
||||
---@field [string] table<string, ContestData>
|
||||
---@field file_states? table<string, FileState>
|
||||
|
|
@ -12,13 +24,6 @@
|
|||
---@class ContestListData
|
||||
---@field contests table[]
|
||||
|
||||
---@class ContestData
|
||||
---@field problems Problem[]
|
||||
---@field test_cases? CachedTestCase[]
|
||||
---@field timeout_ms? number
|
||||
---@field memory_mb? number
|
||||
---@field interactive? boolean
|
||||
|
||||
---@class Problem
|
||||
---@field id string
|
||||
---@field name? string
|
||||
|
|
@ -36,6 +41,8 @@ local cache_file = vim.fn.stdpath('data') .. '/cp-nvim.json'
|
|||
local cache_data = {}
|
||||
local loaded = false
|
||||
|
||||
--- Load the cache from disk if not done already
|
||||
---@return nil
|
||||
function M.load()
|
||||
if loaded then
|
||||
return
|
||||
|
|
@ -63,6 +70,8 @@ function M.load()
|
|||
loaded = true
|
||||
end
|
||||
|
||||
--- Save the cache to disk, overwriting existing contents
|
||||
---@return nil
|
||||
function M.save()
|
||||
vim.schedule(function()
|
||||
vim.fn.mkdir(vim.fn.fnamemodify(cache_file, ':h'), 'p')
|
||||
|
|
@ -260,8 +269,8 @@ function M.set_file_state(file_path, platform, contest_id, problem_id, language)
|
|||
end
|
||||
|
||||
---@param platform string
|
||||
---@return table[]
|
||||
function M.get_contest_list(platform)
|
||||
---@return table[ContestSummary]
|
||||
function M.get_contest_summaries(platform)
|
||||
local contest_list = {}
|
||||
for contest_id, contest_data in pairs(cache_data[platform] or {}) do
|
||||
table.insert(contest_list, {
|
||||
|
|
@ -274,8 +283,8 @@ function M.get_contest_list(platform)
|
|||
end
|
||||
|
||||
---@param platform string
|
||||
---@param contests table[]
|
||||
function M.set_contest_list(platform, contests)
|
||||
---@param contests table[ContestSummary]
|
||||
function M.set_contest_summaries(platform, contests)
|
||||
cache_data[platform] = cache_data[platform] or {}
|
||||
for _, contest in ipairs(contests) do
|
||||
cache_data[platform][contest.id] = cache_data[platform][contest] or {}
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ function M.get_platform_contests(platform, refresh)
|
|||
|
||||
cache.load()
|
||||
|
||||
local picker_contests = cache.get_contest_list(platform)
|
||||
local picker_contests = cache.get_contest_summaries(platform)
|
||||
|
||||
if refresh or vim.tbl_isempty(picker_contests) then
|
||||
logger.log(('Cache miss on %s contests'):format(platform))
|
||||
local contests = scraper.scrape_contest_list(platform)
|
||||
|
||||
cache.set_contest_list(platform, contests)
|
||||
cache.set_contest_summaries(platform, contests)
|
||||
end
|
||||
|
||||
logger.log(
|
||||
|
|
@ -64,7 +64,7 @@ function M.get_platform_contests(platform, refresh)
|
|||
true
|
||||
)
|
||||
|
||||
picker_contests = cache.get_contest_list(platform)
|
||||
picker_contests = cache.get_contest_summaries(platform)
|
||||
|
||||
return picker_contests
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,11 +7,6 @@
|
|||
---@field set_problem_id fun(problem_id: string)
|
||||
---@field get_active_panel fun(): string?
|
||||
---@field set_active_panel fun(): string?
|
||||
---@field get_saved_session fun(): table?
|
||||
---@field set_saved_session fun(session: table)
|
||||
---@field get_context fun(): {platform: string?, contest_id: string?, problem_id: string?}
|
||||
---@field has_context fun(): boolean
|
||||
---@field reset fun()
|
||||
---@field get_base_name fun(): string?
|
||||
---@field get_source_file fun(language?: string): string?
|
||||
---@field get_binary_file fun(): string?
|
||||
|
|
@ -54,14 +49,6 @@ function M.set_problem_id(problem_id)
|
|||
state.problem_id = problem_id
|
||||
end
|
||||
|
||||
function M.get_saved_session()
|
||||
return state.saved_session
|
||||
end
|
||||
|
||||
function M.set_saved_session(session)
|
||||
state.saved_session = session
|
||||
end
|
||||
|
||||
function M.get_base_name()
|
||||
local platform, contest_id, problem_id = M.get_platform(), M.get_contest_id(), M.get_problem_id()
|
||||
if not platform or not contest_id or not problem_id then
|
||||
|
|
@ -78,14 +65,6 @@ function M.get_base_name()
|
|||
end
|
||||
end
|
||||
|
||||
function M.get_context()
|
||||
return {
|
||||
platform = state.platform,
|
||||
contest_id = state.contest_id,
|
||||
problem_id = state.problem_id,
|
||||
}
|
||||
end
|
||||
|
||||
function M.get_source_file(language)
|
||||
local base_name = M.get_base_name()
|
||||
if not base_name or not M.get_platform() then
|
||||
|
|
@ -127,10 +106,6 @@ function M.get_expected_file()
|
|||
return base_name and ('io/%s.expected'):format(base_name) or nil
|
||||
end
|
||||
|
||||
function M.has_context()
|
||||
return state.platform and state.contest_id
|
||||
end
|
||||
|
||||
function M.get_active_panel()
|
||||
return state.active_panel
|
||||
end
|
||||
|
|
@ -139,13 +114,4 @@ function M.set_active_panel(panel)
|
|||
state.active_panel = panel
|
||||
end
|
||||
|
||||
function M.reset()
|
||||
state.platform = nil
|
||||
state.contest_id = nil
|
||||
state.problem_id = nil
|
||||
state.test_cases = nil
|
||||
state.run_panel_active = false
|
||||
state.saved_session = nil
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue