feat: add reverse relation mappings#17
Open
inchei wants to merge 2 commits into
Open
Conversation
trim21
requested changes
May 8, 2026
Contributor
trim21
left a comment
There was a problem hiding this comment.
审查:subject_relations.yml 对照 Bangumi 现有代码
审查依据:比对 Bangumi/lib/SubjectRelation.class.php 中 convertRelations() 的现有交换集。
Bug:Game→Game 缺少 GAME_VERSION → GAME_MAIN_VERSION(4016 → 4017)
当前 Game→Game 同类型映射中:
*TYPE_GAME :
*TYPE_GAME :
*GAME_MAIN_VERSION : *GAME_VERSION # 4017 → 4016
*GAME_COLLECTION : *GAME_IN_COLLECTION # 4018 → 4019
*GAME_IN_COLLECTION : *GAME_COLLECTION # 4019 → 4018
# 缺少:*GAME_VERSION : *GAME_MAIN_VERSION ← 4016 → 4017PHP 中对应逻辑同时包含双向:
self::TYPE_GAME_VERSION => self::TYPE_GAME_MAIN_VERSION, // 4016 → 4017
self::TYPE_GAME_MAIN_VERSION => self::TYPE_GAME_VERSION, // 4017 → 4016后果:用户将 A 设为 B 的不同版本(4016) 时,getReverseRelation 找不到映射,fallback 返回 4016 自身,导致反向也是不同版本而非主版本。
建议在 Game→Game 段补充 *GAME_VERSION : *GAME_MAIN_VERSION。
行为差异:ANIME_PARENT_STORY (12) 的反向映射
PHP 实际运行时由于 duplicate key 覆盖:
12 => 6, // 被覆盖
12 => 11, // 覆盖后生效,Parent Story → Spin-off实际 PHP 中 PARENT_STORY(12) 反向是 SPIN_OFF(11)。
PR 中映射为:
*ANIME_PARENT_STORY : *ANIME_SIDE_STORY # 12 → 6 而非 11PR 选择映射到概念更广泛的 SIDE_STORY(番外篇),语义上更合理,但这与 PHP 现有运行时行为不同。需确认是否有存量数据依赖 PHP 的 12 → 11 逻辑。
补充确认点
- PHP 中 Game exchange_set 含
4004/4005幽灵 ID(不在 YAML types 中),YAML 的relation_ids未包含,PR 无此问题 - 合并后需重新编译
subject_relations.json,当前 JSON 不含relation_ids和relation_mappings - 跨类型的对称映射(如 Character、Same Setting 等 fallback 到自身)符合预期,book→book 缺少
BOOK_VERSION映射也属合理
Author
|
不同版本对应的不一定是主版本,也可能是不同版本吧 |
Member
这个不能乱改,主版本是特殊逻辑。 |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bangumi/server-private#1512