Skip to content

Fix other creator types returned as author#1352

Open
Xiao-Chenguang wants to merge 2 commits intoMuiseDestiny:masterfrom
Xiao-Chenguang:master
Open

Fix other creator types returned as author#1352
Xiao-Chenguang wants to merge 2 commits intoMuiseDestiny:masterfrom
Xiao-Chenguang:master

Conversation

@Xiao-Chenguang
Copy link
Copy Markdown

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 getAuthors which get more than authors. With one more filter on creator type (author is 8), this could be fixed.

@safe1ine
Copy link
Copy Markdown

safe1ine commented Feb 5, 2026

@MonkeyCode-AI review 一下

@MonkeyCode-AI
Copy link
Copy Markdown

MonkeyCode-AI 正在分析任务...

Copy link
Copy Markdown

@MonkeyCode-AI MonkeyCode-AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我是 MonkeyCode AI 编程助手,你可以在 GitHub 仓库的 PR 中 at @MonkeyCode-AI 来呼唤我。

任务执行细节请参考: https://monkeycode-ai.com

代码审查结果

通过在作者抽取逻辑中增加 creatorTypeID 过滤,修复了将编辑等其他角色误当作者导致的错误关联问题,变更小且方向正确。

🚨 Critical ⚠️ Warning 💡 Suggestion
0 1 1

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 => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

⚠️ 使用硬编码 creatorTypeID==8 可维护性差且可能在不同环境/版本下不稳定

当前直接以数值 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants