mirror of
https://github.com/go-gitea/gitea
synced 2025-07-27 04:38:36 +00:00
chore: fix duplicate to satisfy
This commit is contained in:
@@ -30,23 +30,10 @@ func (comments CommentList) LoadPosters(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
posterIDs := comments.getPosterIDs()
|
posterMaps, err := getPosters(ctx, comments.getPosterIDs())
|
||||||
posterMaps := make(map[int64]*user_model.User, len(posterIDs))
|
|
||||||
left := len(posterIDs)
|
|
||||||
for left > 0 {
|
|
||||||
limit := db.DefaultMaxInSize
|
|
||||||
if left < limit {
|
|
||||||
limit = left
|
|
||||||
}
|
|
||||||
err := db.GetEngine(ctx).
|
|
||||||
In("id", posterIDs[:limit]).
|
|
||||||
Find(&posterMaps)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
left -= limit
|
|
||||||
posterIDs = posterIDs[limit:]
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, comment := range comments {
|
for _, comment := range comments {
|
||||||
if comment.PosterID == user_model.BotUserID {
|
if comment.PosterID == user_model.BotUserID {
|
||||||
|
@@ -87,23 +87,10 @@ func (issues IssueList) loadPosters(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
posterIDs := issues.getPosterIDs()
|
posterMaps, err := getPosters(ctx, issues.getPosterIDs())
|
||||||
posterMaps := make(map[int64]*user_model.User, len(posterIDs))
|
|
||||||
left := len(posterIDs)
|
|
||||||
for left > 0 {
|
|
||||||
limit := db.DefaultMaxInSize
|
|
||||||
if left < limit {
|
|
||||||
limit = left
|
|
||||||
}
|
|
||||||
err := db.GetEngine(ctx).
|
|
||||||
In("id", posterIDs[:limit]).
|
|
||||||
Find(&posterMaps)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
left -= limit
|
|
||||||
posterIDs = posterIDs[limit:]
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, issue := range issues {
|
for _, issue := range issues {
|
||||||
if issue.PosterID == user_model.BotUserID {
|
if issue.PosterID == user_model.BotUserID {
|
||||||
@@ -120,6 +107,26 @@ func (issues IssueList) loadPosters(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPosters(ctx context.Context, posterIDs []int64) (map[int64]*user_model.User, error) {
|
||||||
|
posterMaps := make(map[int64]*user_model.User, len(posterIDs))
|
||||||
|
left := len(posterIDs)
|
||||||
|
for left > 0 {
|
||||||
|
limit := db.DefaultMaxInSize
|
||||||
|
if left < limit {
|
||||||
|
limit = left
|
||||||
|
}
|
||||||
|
err := db.GetEngine(ctx).
|
||||||
|
In("id", posterIDs[:limit]).
|
||||||
|
Find(&posterMaps)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
left -= limit
|
||||||
|
posterIDs = posterIDs[limit:]
|
||||||
|
}
|
||||||
|
return posterMaps, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (issues IssueList) getIssueIDs() []int64 {
|
func (issues IssueList) getIssueIDs() []int64 {
|
||||||
ids := make([]int64, 0, len(issues))
|
ids := make([]int64, 0, len(issues))
|
||||||
for _, issue := range issues {
|
for _, issue := range issues {
|
||||||
|
Reference in New Issue
Block a user