Skip to content

Commit

Permalink
流水线名称的排序没有按a~Z,导致了中英混杂的情况 TencentBlueKing#8508
Browse files Browse the repository at this point in the history
  • Loading branch information
yongyiduan committed Mar 21, 2023
1 parent 30237b4 commit d8d9697
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ package com.tencent.devops.common.util
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import java.text.Collator
import java.util.Locale

class PinyinUtilTest {

@Test
fun test() {
val list = listOf("a", "", "", "c", "", "b")
val list = listOf("a", "", "", "c", "", "b", "にっ", "русский язык")
val res = list.sortedWith(
Comparator { a, b ->
Collator.getInstance(Locale.CHINESE).compare(a, b)
Collator.getInstance().compare(a, b)
}
)
Assertions.assertEquals(res.joinToString(separator = ""), "abc啊博刺")
Assertions.assertEquals(res.joinToString(separator = ""), "abcにっрусский язык啊博刺")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import java.text.Collator
import java.time.LocalDateTime
import java.util.Locale
import java.util.concurrent.TimeUnit

@Service
Expand Down Expand Up @@ -701,7 +700,7 @@ class PipelineViewGroupService @Autowired constructor(
val viewScoreMap = pipelineViewTopDao.list(dslContext, projectId, userId).associate { it.viewId to score++ }

return views.sortedWith(Comparator { a, b ->
Collator.getInstance(Locale.CHINESE).compare(a.name, b.name)
Collator.getInstance().compare(a.name, b.name)
}).sortedBy {
viewScoreMap[it.id] ?: Int.MAX_VALUE
}.map {
Expand Down

0 comments on commit d8d9697

Please sign in to comment.