Skip to content

Commit 59b9311

Browse files
committed
improve
1 parent 9fcb6b7 commit 59b9311

File tree

2 files changed

+10
-26
lines changed

2 files changed

+10
-26
lines changed

models/git/branch.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -464,18 +464,17 @@ func FindRecentlyPushedNewBranches(ctx context.Context, doer *user_model.User, o
464464

465465
// find all related branches, these branches may already created PRs, we will check later
466466
var branches []*Branch
467-
cond := FindBranchOptions{
468-
PusherID: doer.ID,
469-
IsDeletedBranch: optional.Some(false),
470-
CommitAfterUnix: opts.CommitAfterUnix,
471-
}.ToConds()
472-
cond = cond.And(
473-
builder.In("repo_id", repoIDs),
474-
// newly created branch have no changes, so skip them
475-
builder.Neq{"commit_id": baseBranch.CommitID},
476-
)
477467
if err := db.GetEngine(ctx).
478-
Where(cond).
468+
Where(builder.And(
469+
builder.Eq{
470+
"pusher_id": doer.ID,
471+
"is_deleted": false,
472+
},
473+
builder.Gte{"commit_time": opts.CommitAfterUnix},
474+
builder.In("repo_id", repoIDs),
475+
// newly created branch have no changes, so skip them
476+
builder.Neq{"commit_id": baseBranch.CommitID},
477+
)).
479478
OrderBy(db.SearchOrderByRecentUpdated.String()).
480479
Find(&branches); err != nil {
481480
return nil, err

models/git/branch_list.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ type FindBranchOptions struct {
8484
ExcludeBranchNames []string
8585
PusherID int64
8686
IsDeletedBranch optional.Option[bool]
87-
CommitAfterUnix int64
88-
CommitBeforeUnix int64
8987
OrderBy string
9088
Keyword string
9189
}
@@ -100,25 +98,12 @@ func (opts FindBranchOptions) ToConds() builder.Cond {
10098
if len(opts.ExcludeBranchNames) > 0 {
10199
cond = cond.And(builder.NotIn("name", opts.ExcludeBranchNames))
102100
}
103-
104-
if opts.PusherID > 0 {
105-
cond = cond.And(builder.Eq{"pusher_id": opts.PusherID})
106-
}
107-
108101
if opts.IsDeletedBranch.Has() {
109102
cond = cond.And(builder.Eq{"is_deleted": opts.IsDeletedBranch.Value()})
110103
}
111104
if opts.Keyword != "" {
112105
cond = cond.And(builder.Like{"name", opts.Keyword})
113106
}
114-
115-
if opts.CommitAfterUnix != 0 {
116-
cond = cond.And(builder.Gte{"commit_time": opts.CommitAfterUnix})
117-
}
118-
if opts.CommitBeforeUnix != 0 {
119-
cond = cond.And(builder.Lte{"commit_time": opts.CommitBeforeUnix})
120-
}
121-
122107
return cond
123108
}
124109

0 commit comments

Comments
 (0)