@@ -126,9 +126,8 @@ func (l *Label) CalOpenOrgIssues(ctx context.Context, repoID, labelID int64) {
126126
127127// LoadSelectedLabelsAfterClick calculates the set of selected labels when a label is clicked
128128func (l * Label ) LoadSelectedLabelsAfterClick (currentSelectedLabels []int64 , currentSelectedExclusiveScopes []string ) {
129- labelQueryContainer := make (container. Set [ string ]) // container instead of slice to avoid duplicates
129+ labelQuerySlice := [] int64 {}
130130 labelSelected := false
131- labelID := strconv .FormatInt (l .ID , 10 )
132131 labelScope := l .ExclusiveScope ()
133132 for i , s := range currentSelectedLabels {
134133 if s == l .ID {
@@ -139,19 +138,27 @@ func (l *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []int64, curr
139138 } else if s != 0 {
140139 // Exclude other labels in the same scope from selection
141140 if s < 0 || labelScope == "" || labelScope != currentSelectedExclusiveScopes [i ] {
142- labelQueryContainer . Add ( strconv . FormatInt ( s , 10 ) )
141+ labelQuerySlice = append ( labelQuerySlice , s )
143142 }
144143 }
145144 }
145+
146146 if ! labelSelected {
147- labelQueryContainer . Add ( labelID )
147+ labelQuerySlice = append ( labelQuerySlice , l . ID )
148148 }
149149 l .IsSelected = labelSelected
150+
150151 // sort the ids to avoid the crawlers hitting the same
151152 // page with a different order of parameters
152- sortedLabelQuerySlice := labelQueryContainer .Values ()
153- sort .Strings (sortedLabelQuerySlice )
154- l .QueryString = strings .Join (sortedLabelQuerySlice , "," )
153+ // (still no sort.Ints64 in Go 1.20... Maybe Slice.sort in Go 1.21 ?)
154+ sort .Slice (labelQuerySlice , func (i , j int ) bool { return labelQuerySlice [i ] < labelQuerySlice [j ] })
155+ // Deduplicate using a container
156+ // (maybe again, with Go 1.21 and Slice.compact() ?)
157+ labelQueryContainer := make (container.Set [string ])
158+ for _ , s := range labelQuerySlice {
159+ labelQueryContainer .Add (strconv .FormatInt (s , 10 ))
160+ }
161+ l .QueryString = strings .Join (labelQueryContainer .Values (), "," )
155162}
156163
157164// BelongsToOrg returns true if label is an organization label
0 commit comments