Skip to content

Commit

Permalink
use "optional" correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Dec 10, 2024
1 parent f9dfaa2 commit 6feb95b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions models/issues/issue_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func issuePullAccessibleRepoCond(repoIDstr string, userID int64, org *organizati
}

func applyAssigneeCondition(sess *xorm.Session, assigneeID optional.Option[int64]) {
if assigneeID == nil || assigneeID.Value() == 0 {
if !assigneeID.Has() || assigneeID.Value() == 0 {
return
}
if assigneeID.Value() == db.NoConditionID {
Expand All @@ -365,7 +365,7 @@ func applyAssigneeCondition(sess *xorm.Session, assigneeID optional.Option[int64
}

func applyPosterCondition(sess *xorm.Session, posterID optional.Option[int64]) {
if posterID == nil {
if !posterID.Has() {
return
}
// poster doesn't need to support db.NoConditionID(-1), so just use the value as-is
Expand Down
2 changes: 1 addition & 1 deletion routers/web/org/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func ViewProject(ctx *context.Context) {
if ctx.Written() {
return
}
assigneeID := ctx.FormInt64("assignee")
assigneeID := ctx.FormInt64("assignee") // TODO: use "optional" but not 0 in the future

issuesMap, err := issues_model.LoadIssuesFromColumnList(ctx, columns, &issues_model.IssuesOptions{
LabelIDs: labelIDs,
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/issue_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
viewType = "all"
}

assigneeID := ctx.FormInt64("assignee")
assigneeID := ctx.FormInt64("assignee") // TODO: use "optional" but not 0 in the future
posterUsername := ctx.FormString("poster")
posterUserID := shared_user.GetFilterUserIDByName(ctx, posterUsername)
var mentionedID, reviewRequestedID, reviewedID int64
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func ViewProject(ctx *context.Context) {

labelIDs := issue.PrepareFilterIssueLabels(ctx, ctx.Repo.Repository.ID, ctx.Repo.Owner)

assigneeID := ctx.FormInt64("assignee")
assigneeID := ctx.FormInt64("assignee") // TODO: use "optional" but not 0 in the future

issuesMap, err := issues_model.LoadIssuesFromColumnList(ctx, columns, &issues_model.IssuesOptions{
LabelIDs: labelIDs,
Expand Down
2 changes: 1 addition & 1 deletion routers/web/shared/user/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func MakeSelfOnTop(doer *user.User, users []*user.User) []*user.User {
// * some(NonExistingID): match no issue (due to the user doesn't exist)
func GetFilterUserIDByName(ctx context.Context, name string) optional.Option[int64] {
if name == "" {
return nil
return optional.None[int64]()
}
u, err := user.GetUserByName(ctx, name)
if err != nil {
Expand Down

0 comments on commit 6feb95b

Please sign in to comment.