Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions lua/competitest/receive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,39 @@ end
function storage_utils.eval_receive_modifiers(str, task, file_extension, remove_illegal_characters, date_format)
local judge, contest
local hyphen = string.find(task.group, " - ", 1, true)

if not hyphen then
judge = task.group
contest = "unknown_contest"
else
judge = string.sub(task.group, 1, hyphen - 1)
contest = string.sub(task.group, hyphen + 3)
judge = string.lower(string.sub(task.group, 1, hyphen - 1))
contest = string.lower(string.sub(task.group, hyphen + 3))

if judge == "codeforces" then
local edu_round = contest:match("educational.-codeforces.-round%s*(%d+)")
local global_round = contest:match("codeforces.-global.-round%s*(%d+)")
local cf_round = contest:match("codeforces.-round%s*(%d+)")
local specific_round = contest:match("^(%a+.-round%s*%d+)")

if edu_round then
contest = "edu round " .. edu_round
elseif global_round then
contest = "global round " .. global_round
elseif cf_round then
contest = "round " .. cf_round
elseif specific_round then
contest = specific_round
end
elseif judge == "atcoder" then
local beg_round = contest:match("beginner.-contest%s*(%d+)")
local round = contest:match("contest%s*(%d+)")

if beg_round then
contest = "beg round " .. beg_round
elseif round then
contest = "reg round " .. round
end
end
end

---CompetiTest receive modifiers
Expand Down Expand Up @@ -523,13 +550,15 @@ function storage_utils.store_contest(tasks, cfg, finished)
local_cfg.floating_border,
not local_cfg.received_contests_prompt_extension,
function(file_extension)
opened = false
for _, task in ipairs(tasks) do
local problem_path = storage_utils.eval_path(local_cfg.received_contests_problems_path, task, file_extension)
if problem_path then
local filepath = directory .. "/" .. problem_path
storage_utils.store_received_task_config(filepath, true, task, local_cfg)
if local_cfg.open_received_contests then
if local_cfg.open_received_contests and not opened then
vim.api.nvim_command("edit " .. vim.fn.fnameescape(filepath))
opened = true
end
else
utils.notify("'received_contests_problems_path' evaluation failed for task '" .. task.name .. "'")
Expand Down