hydro-dev / hydro-dev/xcpc-tools

Team/”Load from OJ“ 功能修改数据库 _id 相关报错的可能解决方案

Open Beginner friendly
#17 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
49
Forks
13
PR merge metrics
No merged PRs in 30d

Description

我发现在使用从 OJ 中导入队伍时,会有报错:

Image Image

简单阅读源码后,大致定位问题可能来自 fetcher.ts,293 行的这一段代码:

Image

Hydro 同步队伍时,把带 _id 的整条 team 直接塞进了 set,似乎是导致这个报错的原因。

Image
for (const team of teams) {
            const logo = resolvePublicAssetUrl(team.schoolLogo || team.logo || team.avatar, config.server);
            await this.ctx.db.teams.update({ id: team._id }, {
                $set: {
                    ...team,
                    ...logo && { logo },
                },
            }, { upsert: true });
        }

修改后问题也成功解决了:

Image Image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in fetcher.ts around line 293 and follow the team import path used by “Load from OJ”. Reproduce the team synchronization error, then verify that the database update no longer attempts to write the imported team’s _id and that the import completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
database
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.