Skip to content

Commit

Permalink
feat:推荐版本号优化 TencentBlueKing#10958 版本列表接口排序修复
Browse files Browse the repository at this point in the history
  • Loading branch information
royalhuang committed Sep 26, 2024
1 parent 523166b commit 60b2e87
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,8 @@ class PipelineVersionFacadeService @Autowired constructor(
var limit = slqLimit?.limit ?: -1
val result = mutableListOf<PipelineVersionSimple>()
// 如果有草稿版本需要提到第一页,单独查出来放在第一页并顶置
if (includeDraft != false && page == 1) {
val draftResource = if (includeDraft != false && page == 1) {
limit -= 1
pipelineRepositoryService.getDraftVersionResource(
projectId = projectId,
pipelineId = pipelineId
Expand All @@ -861,11 +862,8 @@ class PipelineVersionFacadeService @Autowired constructor(
projectId, pipelineId, it
)?.versionName
}
}?.let {
limit -= 1
result.add(it)
}
}
} else null
// 如果有要插队的版本需要提到第一页,则在查询list时排除,单独查出来放在第一页
val fromResource = if (fromVersion != null && page == 1) {
limit -= 1
Expand All @@ -875,9 +873,8 @@ class PipelineVersionFacadeService @Autowired constructor(
version = fromVersion
)
} else null

val pipelineInfo = pipelineRepositoryService.getPipelineInfo(projectId, pipelineId)
val (size, pipelines) = repositoryVersionService.listPipelineReleaseVersion(
var (size, pipelines) = repositoryVersionService.listPipelineReleaseVersion(
pipelineInfo = pipelineInfo,
projectId = projectId,
pipelineId = pipelineId,
Expand All @@ -888,8 +885,15 @@ class PipelineVersionFacadeService @Autowired constructor(
offset = offset,
limit = limit
)
draftResource?.let {
size++
result.add(it)
}
result.addAll(pipelines)
fromResource?.let { result.add(it) }
fromResource?.let {
size++
result.add(it)
}
return Page(
page = page,
pageSize = pageSize,
Expand Down

0 comments on commit 60b2e87

Please sign in to comment.