refactor(cyberhub): move draft toggle from Provider to ExportFilter#15
Open
wuchulonly wants to merge 1 commit into
Open
refactor(cyberhub): move draft toggle from Provider to ExportFilter#15wuchulonly wants to merge 1 commit into
wuchulonly wants to merge 1 commit into
Conversation
7e47524 加了 Provider.WithDraft() 把 ?with_draft=true 透传到导出 API。 现在把这个旋钮挪回 ExportFilter,跟 Statuses / ReviewStatus / 其它 With* builder 放一起,理由: - 一致性:所有 export 时的"问什么/怎么问"参数都集中在 ExportFilter, Provider 只负责"地址 / 鉴权 / 超时 / filter"四件事; - 可达:filter.Draft 是值字段,bool 入参的 WithDraft(draft bool) 允许显式 false 关闭(toggle 风格的 Provider.WithDraft() 没办法关); - DRY:with_draft 这条 query 只在 applyFilterParams 里 set 一次, 不再在 exportFingers / exportPOCs 两边各重复一次内联 if。 types.ExportFilter: - 新增 Draft bool 字段; - 新增 WithDraft(draft bool) *ExportFilter builder; - 文档点明它与 Statuses / ReviewStatus 正交(filter 决定"哪些行", Draft 决定"读哪一列")。 pkg/cyberhub/provider.go: - 移除 Provider.draft 字段和 Provider.WithDraft() 方法; - Fingers / POCs 不再传 draft 参数,filter 自己带。 pkg/cyberhub/client.go: - exportFingers / exportPOCs 签名去掉 draft bool 入参; - 删掉两个函数里内联的 `if draft { params.Set("with_draft", "true") }`; - 在 applyFilterParams 里集中处理 with_draft 透传。 pkg/cyberhub/client_test.go: - TestApplyFilterParams_Draft 覆盖 default false / true / 与 Statuses+ ReviewStatus 共存 / nil filter 四种场景; - TestWithDraftBuilder 验证 builder 链返回值; - 新增 TestProvider_DraftBehavior 以 httptest 跑端到端:Fingers + POCs 各两种(不带 Draft / WithDraft+WithReviewStatus),并验证 POCs WithDraft 单独使用时 default active 仍然兜底。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
新增
ExportFilter.WithDraft(draft bool),透传?with_draft=true。Changes
pkg/types/export_filter.go: 加Draft bool字段 +WithDraft(bool)builderpkg/cyberhub/client.go:applyFilterParams里filter.Draft为 true 时params.Set("with_draft", "true")pkg/cyberhub/provider.go: 移除上一条 commit (7e47524) 引入的Provider.WithDraft()/Provider.draft,统一用 filterpkg/cyberhub/client_test.go: 单元 + httptest 端到端