@@ -7,10 +7,12 @@ package issues
77import (
88 "context"
99 "fmt"
10+ "sort"
1011 "strconv"
1112 "strings"
1213
1314 "code.gitea.io/gitea/models/db"
15+ "code.gitea.io/gitea/modules/container"
1416 "code.gitea.io/gitea/modules/label"
1517 "code.gitea.io/gitea/modules/timeutil"
1618 "code.gitea.io/gitea/modules/util"
@@ -124,7 +126,7 @@ func (l *Label) CalOpenOrgIssues(ctx context.Context, repoID, labelID int64) {
124126
125127// LoadSelectedLabelsAfterClick calculates the set of selected labels when a label is clicked
126128func (l * Label ) LoadSelectedLabelsAfterClick (currentSelectedLabels []int64 , currentSelectedExclusiveScopes []string ) {
127- var labelQuerySlice [] string
129+ labelQueryContainer := make (container. Set [ string ]) // container instead of slice to avoid duplicates
128130 labelSelected := false
129131 labelID := strconv .FormatInt (l .ID , 10 )
130132 labelScope := l .ExclusiveScope ()
@@ -137,15 +139,19 @@ func (l *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []int64, curr
137139 } else if s != 0 {
138140 // Exclude other labels in the same scope from selection
139141 if s < 0 || labelScope == "" || labelScope != currentSelectedExclusiveScopes [i ] {
140- labelQuerySlice = append ( labelQuerySlice , strconv .FormatInt (s , 10 ))
142+ labelQueryContainer . Add ( strconv .FormatInt (s , 10 ))
141143 }
142144 }
143145 }
144146 if ! labelSelected {
145- labelQuerySlice = append ( labelQuerySlice , labelID )
147+ labelQueryContainer . Add ( labelID )
146148 }
147149 l .IsSelected = labelSelected
148- l .QueryString = strings .Join (labelQuerySlice , "," )
150+ // sort the ids to avoid the crawlers hitting the same
151+ // page with a different order of parameters
152+ sortedLabelQuerySlice := labelQueryContainer .Values ()
153+ sort .Strings (sortedLabelQuerySlice )
154+ l .QueryString = strings .Join (sortedLabelQuerySlice , "," )
149155}
150156
151157// BelongsToOrg returns true if label is an organization label
0 commit comments