Skip to content

Commit

Permalink
pref:优化流水线项目下已安装插件关联流水线查询 TencentBlueKing#11307
Browse files Browse the repository at this point in the history
  • Loading branch information
yjieliang committed Dec 16, 2024
1 parent 4722043 commit 64f425c
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ package com.tencent.devops.process.engine.dao

import com.tencent.devops.common.api.constant.KEY_VERSION
import com.tencent.devops.common.api.util.JsonUtil
import com.tencent.devops.common.pipeline.enums.ChannelCode
import com.tencent.devops.common.security.util.BkCryptoUtil
import com.tencent.devops.model.process.Tables.T_PIPELINE_MODEL_TASK
import com.tencent.devops.model.process.tables.TPipelineInfo
Expand Down Expand Up @@ -103,9 +102,12 @@ class PipelineModelTaskDao {
*/
fun getPipelineCountByAtomCode(dslContext: DSLContext, atomCode: String, projectCode: String?): Int {
with(TPipelineModelTask.T_PIPELINE_MODEL_TASK) {
val condition = getListByAtomCodeCond(this, atomCode, projectCode)
val condition = mutableListOf<Condition>()
val tpi = TPipelineInfo.T_PIPELINE_INFO
condition.add(tpi.CHANNEL.notEqual(ChannelCode.AM.name))
condition.add(ATOM_CODE.eq(atomCode))
if (projectCode != null) {
condition.add(tpi.PROJECT_ID.eq(projectCode))
}
return dslContext.select(DSL.countDistinct(PIPELINE_ID))
.from(this)
.join(tpi)
Expand All @@ -126,11 +128,10 @@ class PipelineModelTaskDao {
with(TPipelineModelTask.T_PIPELINE_MODEL_TASK) {
val condition = mutableListOf<Condition>()
condition.add(ATOM_CODE.`in`(atomCodeList))
val tpi = TPipelineInfo.T_PIPELINE_INFO
if (projectCode != null) {
condition.add(PROJECT_ID.eq(projectCode))
condition.add(tpi.PROJECT_ID.eq(projectCode))
}
val tpi = TPipelineInfo.T_PIPELINE_INFO
condition.add(tpi.CHANNEL.notEqual(ChannelCode.AM.name))
return dslContext.select(DSL.countDistinct(PIPELINE_ID), ATOM_CODE)
.from(this)
.join(tpi)
Expand Down Expand Up @@ -223,13 +224,15 @@ class PipelineModelTaskDao {
val condition = getListByAtomCodeCond(
a = this,
atomCode = atomCode,
projectId = projectId,
projectId = null,
version = version,
startUpdateTime = startUpdateTime,
endUpdateTime = endUpdateTime
)
val tpi = TPipelineInfo.T_PIPELINE_INFO
condition.add(tpi.CHANNEL.notEqual(ChannelCode.AM.name))
if (!projectId.isNullOrEmpty()) {
condition.add(tpi.PROJECT_ID.eq(projectId))
}
val baseStep = dslContext.select(
PIPELINE_ID.`as`(KEY_PIPELINE_ID),
PROJECT_ID.`as`(KEY_PROJECT_ID),
Expand Down

0 comments on commit 64f425c

Please sign in to comment.