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 a0a37d7 commit 0829096
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,12 @@ class PipelineModelTaskDao {
val condition = getListByAtomCodeCond(
a = this,
atomCode = atomCode,
projectId = null,
projectId = projectId,
version = version,
startUpdateTime = startUpdateTime,
endUpdateTime = endUpdateTime
)
val tpi = TPipelineInfo.T_PIPELINE_INFO
if (!projectId.isNullOrEmpty()) {
condition.add(tpi.PROJECT_ID.eq(projectId))
}
condition.add(tpi.CHANNEL.notEqual(ChannelCode.AM.name))
val baseStep = dslContext.select(
PIPELINE_ID.`as`(KEY_PIPELINE_ID),
PROJECT_ID.`as`(KEY_PROJECT_ID),
Expand All @@ -245,6 +241,7 @@ class PipelineModelTaskDao {
.from(this)
.join(tpi)
.on(PIPELINE_ID.eq(tpi.PIPELINE_ID))
.and(PROJECT_ID.eq(tpi.PROJECT_ID))
.where(condition)
.groupBy(PIPELINE_ID)
.orderBy(UPDATE_TIME.desc(), PIPELINE_ID.desc())
Expand Down Expand Up @@ -274,7 +271,13 @@ class PipelineModelTaskDao {
startUpdateTime = startUpdateTime,
endUpdateTime = endUpdateTime
)
return dslContext.select(DSL.countDistinct(PIPELINE_ID)).from(this).where(condition)
val tpi = TPipelineInfo.T_PIPELINE_INFO
return dslContext.select(DSL.countDistinct(PIPELINE_ID))
.from(this)
.join(tpi)
.on(PIPELINE_ID.eq(tpi.PIPELINE_ID))
.and(PROJECT_ID.eq(tpi.PROJECT_ID))
.where(condition)
.fetchOne(0, Long::class.java)!!
}
}
Expand All @@ -289,9 +292,11 @@ class PipelineModelTaskDao {
): MutableList<Condition> {
val condition = mutableListOf<Condition>()
condition.add(a.ATOM_CODE.eq(atomCode))
val tpi = TPipelineInfo.T_PIPELINE_INFO
if (!projectId.isNullOrEmpty()) {
condition.add(a.PROJECT_ID.eq(projectId))
condition.add(tpi.PROJECT_ID.eq(projectId))
}
condition.add(tpi.CHANNEL.notEqual(ChannelCode.AM.name))
if (!version.isNullOrEmpty()) {
condition.add(a.ATOM_VERSION.contains(version))
}
Expand All @@ -310,17 +315,14 @@ class PipelineModelTaskDao {
pipelineIds: Set<String>
): Result<out Record>? {
with(TPipelineModelTask.T_PIPELINE_MODEL_TASK) {
val condition = getListByAtomCodeCond(this, atomCode, null)

val baseStep = dslContext.select(
return dslContext.select(
PIPELINE_ID.`as`(KEY_PIPELINE_ID),
ATOM_VERSION.`as`(KEY_VERSION)
)
.from(this)
.where(condition)
.where(ATOM_CODE.eq(atomCode))
.and(PIPELINE_ID.`in`(pipelineIds))

return baseStep.fetch()
.fetch()
}
}

Expand Down

0 comments on commit 0829096

Please sign in to comment.