From 60b2e87746a5eebf98ed56105d00e0ef464d21bb Mon Sep 17 00:00:00 2001 From: royalhuang Date: Thu, 26 Sep 2024 16:30:00 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=8E=A8=E8=8D=90=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E4=BC=98=E5=8C=96=20#10958=20=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/PipelineVersionFacadeService.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineVersionFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineVersionFacadeService.kt index 31f22e24332..b9de79ed072 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineVersionFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineVersionFacadeService.kt @@ -851,7 +851,8 @@ class PipelineVersionFacadeService @Autowired constructor( var limit = slqLimit?.limit ?: -1 val result = mutableListOf() // 如果有草稿版本需要提到第一页,单独查出来放在第一页并顶置 - if (includeDraft != false && page == 1) { + val draftResource = if (includeDraft != false && page == 1) { + limit -= 1 pipelineRepositoryService.getDraftVersionResource( projectId = projectId, pipelineId = pipelineId @@ -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 @@ -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, @@ -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,