Fix other creator types returned as author#1352
Open
Xiao-Chenguang wants to merge 2 commits intoMuiseDestiny:masterfrom
Open
Fix other creator types returned as author#1352Xiao-Chenguang wants to merge 2 commits intoMuiseDestiny:masterfrom
Xiao-Chenguang wants to merge 2 commits intoMuiseDestiny:masterfrom
Conversation
|
@MonkeyCode-AI review 一下 |
|
MonkeyCode-AI 正在分析任务... |
MonkeyCode-AI
left a comment
There was a problem hiding this comment.
我是 MonkeyCode AI 编程助手,你可以在 GitHub 仓库的 PR 中 at @MonkeyCode-AI 来呼唤我。
任务执行细节请参考: https://monkeycode-ai.com
代码审查结果
通过在作者抽取逻辑中增加 creatorTypeID 过滤,修复了将编辑等其他角色误当作者导致的错误关联问题,变更小且方向正确。
| 🚨 Critical | 💡 Suggestion | |
|---|---|---|
| 0 | 1 | 1 |
src/modules/graphView.ts
Outdated
| private getGraphByAuthorLink(items: Zotero.Item[]) { | ||
| let getAuthors = (item: Zotero.Item) => { | ||
| return item.getCreators().map(a => { | ||
| return item.getCreators().filter(a => a.creatorTypeID == 8).map(a => { |
There was a problem hiding this comment.
Warning
当前直接以数值 8 代表“author”进行过滤。该魔法数字缺少语义,后续维护者难以理解;同时若 Zotero 的 creatorTypeID 在不同版本/本地化/数据源下存在差异或扩展(例如不同 itemType 的 creatorTypes),硬编码可能导致作者被误过滤或漏过滤。更稳妥的方式是基于 creatorType(字符串)或通过 Zotero API 查询 author 对应的类型 ID(若可用)。
建议: 将 8 抽成具名常量并添加注释;如有可用 API,优先按 creatorType 字符串/动态查询 author 的 typeID,避免魔法数字散落。
Suggested change
| return item.getCreators().filter(a => a.creatorTypeID == 8).map(a => { | |
| let getAuthors = (item: Zotero.Item) => { | |
| // creatorTypeID: 8 means "author" in Zotero creator types | |
| const AUTHOR_CREATOR_TYPE_ID = 8 | |
| return item.getCreators().filter(a => a.creatorTypeID === AUTHOR_CREATOR_TYPE_ID).map(a => { | |
| return `${a.firstName} ${a.lastName}` | |
| }) | |
| } |
More robust author name processing. Co-authored-by: MonkeyCode-AI <[email protected]>
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.
Author graph include wrong link of other creator types (e.g. editor). This lead to wrong link between papers doesn't share any author but published in the same journal/procceeding as the editors are the same. The error located in the function
getAuthorswhich get more than authors. With one more filter on creator type (author is 8), this could be fixed.