-
Notifications
You must be signed in to change notification settings - Fork 3
refactor(api): change StoryID and IterationID types to improve data handling #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…andling Signed-off-by: Flc <[email protected]>
WalkthroughThe changes update the types of several struct fields: the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API
participant DB
Client->>API: Send GetTasksRequest (StoryID, IterationID as int64)
API->>DB: Query tasks using int64 IDs
DB-->>API: Return tasks data
API-->>Client: Respond with tasks
Client->>API: Send/Receive Story (Status as StoryStatus)
API-->>Client: Respond with Story (Status as StoryStatus)
Possibly related PRs
Suggested labels
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
api_story.go (1)
8-23
: Good move toward strong typing, but consider adding (Un)Marshal helpersUsing a dedicated
StoryStatus
enum improves type-safety and discoverability—nice 🎉.
If other packages (e.g.encoding/json
,database/sql
) must round-trip this value, you may want to addMarshalText
/UnmarshalText
(orMarshalJSON
/UnmarshalJSON
) methods so that invalid values fail fast and custom validation is centralized.func (s StoryStatus) MarshalText() ([]byte, error) { switch s { // whitelist case StoryStatusAudited, StoryStatusDeveloping, StoryStatusForTest, StoryStatusInProgress, StoryStatusPlanning, StoryStatusRejected, StoryStatusResolved, StoryStatusTesting: return []byte(s), nil default: return nil, fmt.Errorf("unknown StoryStatus %q", s) } }api_task.go (1)
277-278
: Mirror the change inGetTasksCountRequest
comments/docstringsThe same ID fields were updated here—good.
Minor nit: the inline comments still say “ID 支持多ID查询” without mentioning they are numeric IDs now. Updating the comment would prevent confusion for SDK users skimming the source.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
api_story.go
(1 hunks)api_task.go
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
api_task.go (1)
api_types.go (2)
Multi
(19-19)Enum
(66-66)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: go test (1.24.x, windows-latest)
- GitHub Check: go test (1.23.x, windows-latest)
🔇 Additional comments (3)
api_story.go (2)
60-60
: Inconsistent status types across request/response structs
Story.Status
is nowStoryStatus
, butUpdateStoryRequest.Status
andGetStoriesCountRequest.Status
remain*string
.
That asymmetry forces manual casts in client code and re-opens the door to typo errors when updating stories or counting them.Consider aligning those request structs to
*StoryStatus
(or*Enum[StoryStatus]
where applicable) for a fully type-safe API surface.
317-318
: URL encoding of genericEnum[StoryStatus]
may need special handlingSwapping from
Enum[string]
toEnum[StoryStatus]
means the URL encoder now receives a slice of custom types.
If the encoder relies onfmt.Sprint
it will still work, but if it expects[]string
you’ll get an empty parameter list or a compile error.Please verify that
urlencoder.Encode(...)
(or whichever helper lives in this repo) correctly serializesEnum[StoryStatus]
to the comma-separated strings the TAPD API expects.api_task.go (1)
197-199
: Type change improves safety but double-check URL marshalling
StoryID
andIterationID
inGetTasksRequest
are now*Multi[int64]
/*Enum[int64]
.
👍 for matching the server’s numeric IDs, but ensure your query encoder still joins them with commas (e.g.123,456
) instead of producing repeated parameters or[123 456]
.
A quick unit test aroundencodeURL(GetTasksRequest{StoryID: &Multi[int64]{123,456}})
would catch regressions.
Summary by CodeRabbit