Use Set[Type]
instead of map[Type]bool/struct{}
. (#26804)
This commit is contained in:
parent
815d267c80
commit
5315153059
9 changed files with 36 additions and 48 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
secret_model "code.gitea.io/gitea/models/secret"
|
||||
actions_module "code.gitea.io/gitea/modules/actions"
|
||||
"code.gitea.io/gitea/modules/container"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
@ -197,10 +198,7 @@ func findTaskNeeds(ctx context.Context, task *actions_model.ActionTask) (map[str
|
|||
if len(task.Job.Needs) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
needs := map[string]struct{}{}
|
||||
for _, v := range task.Job.Needs {
|
||||
needs[v] = struct{}{}
|
||||
}
|
||||
needs := container.SetOf(task.Job.Needs...)
|
||||
|
||||
jobs, _, err := actions_model.FindRunJobs(ctx, actions_model.FindRunJobOptions{RunID: task.Job.RunID})
|
||||
if err != nil {
|
||||
|
@ -209,7 +207,7 @@ func findTaskNeeds(ctx context.Context, task *actions_model.ActionTask) (map[str
|
|||
|
||||
ret := make(map[string]*runnerv1.TaskNeed, len(needs))
|
||||
for _, job := range jobs {
|
||||
if _, ok := needs[job.JobID]; !ok {
|
||||
if !needs.Contains(job.JobID) {
|
||||
continue
|
||||
}
|
||||
if job.TaskID == 0 || !job.Status.IsDone() {
|
||||
|
|
|
@ -567,12 +567,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
|
|||
|
||||
// Remove repositories that should not be shown,
|
||||
// which are repositories that have no issues and are not selected by the user.
|
||||
selectedReposMap := make(map[int64]struct{}, len(selectedRepoIDs))
|
||||
for _, repoID := range selectedRepoIDs {
|
||||
selectedReposMap[repoID] = struct{}{}
|
||||
}
|
||||
selectedRepos := container.SetOf(selectedRepoIDs...)
|
||||
for k, v := range issueCountByRepo {
|
||||
if _, ok := selectedReposMap[k]; !ok && v == 0 {
|
||||
if v == 0 && !selectedRepos.Contains(k) {
|
||||
delete(issueCountByRepo, k)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue