Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork6.3k
refactor: extract helper functions from SearchIssues#36158
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Extract parseIssueIsClosed, parseIssueIsPull, and buildSearchIssuesRepoIDshelper functions to improve code readability and maintainability.- parseIssueIsClosed: parses "state" query parameter- parseIssueIsPull: parses "type" query parameter- buildSearchIssuesRepoIDs: builds repository IDs for issue searchAlso consolidate error handling conditions using || operator.
e04b0bd to8909fceComparebimakw commentedDec 18, 2025
Thanks@lunny for the review! Updated to use |
| iferr!=nil { | ||
| repoIDs,allPublic,err:=buildSearchIssuesRepoIDs(ctx) | ||
| iferr!=nil { | ||
| ifuser_model.IsErrUserNotExist(err)||organization.IsErrTeamNotExist(err)||err.Error()=="owner organisation is required for filtering on team" { |
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.
err.Error() == "owner organisation is required for filtering on team"
please don't do this, it is an abuse to Golang error system and is very fragile.
Summary
This PR refactors the
SearchIssuesfunction inrouters/api/v1/repo/issue.goby extracting common logic into reusable helper functions:parseIssueIsClosed(): Parses the "state" query parameter and returns the correspondingisClosedoptionparseIssueIsPull(): Parses the "type" query parameter and returns the correspondingisPulloptionbuildSearchIssuesRepoIDs(): Builds the list of repository IDs for issue search based on query parametersBenefits:
Changes:
SearchIssuesfunctionTest plan
/repos/issues/searchendpointRef:#35015