hydro-dev / hydro-dev/xcpc-tools
Team/”Load from OJ“ 功能修改数据库 _id 相关报错的可能解决方案
Open
Beginner friendly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 49
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
我发现在使用从 OJ 中导入队伍时,会有报错:
简单阅读源码后,大致定位问题可能来自 fetcher.ts,293 行的这一段代码:
Hydro 同步队伍时,把带 _id 的整条 team 直接塞进了 set,似乎是导致这个报错的原因。
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 });
}
修改后问题也成功解决了:
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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