Skip to content

Commit

Permalink
Merge pull request #10425 from stubenhuang/issue-recycle-search-10408
Browse files Browse the repository at this point in the history
feat: 回收站支持流水线名词搜索 #10408
  • Loading branch information
bkci-bot authored May 31, 2024
2 parents 85499b5 + 04f2a00 commit bab9bc1
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import com.tencent.devops.common.api.pojo.Page
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.pipeline.Model
import com.tencent.devops.common.pipeline.pojo.MatrixPipelineInfo
import com.tencent.devops.common.pipeline.pojo.PipelineModelAndSetting
import com.tencent.devops.common.pipeline.pojo.setting.PipelineSetting
import com.tencent.devops.common.web.annotation.BkApiPermission
import com.tencent.devops.common.web.constant.BkApiHandleType
import com.tencent.devops.process.engine.pojo.PipelineInfo
Expand All @@ -52,11 +54,9 @@ import com.tencent.devops.process.pojo.classify.PipelineViewAndPipelines
import com.tencent.devops.process.pojo.classify.PipelineViewPipelinePage
import com.tencent.devops.process.pojo.pipeline.BatchDeletePipeline
import com.tencent.devops.process.pojo.pipeline.PipelineCount
import com.tencent.devops.common.pipeline.pojo.PipelineModelAndSetting
import com.tencent.devops.common.pipeline.pojo.setting.PipelineSetting
import io.swagger.v3.oas.annotations.tags.Tag
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.tags.Tag
import javax.validation.Valid
import javax.ws.rs.Consumes
import javax.ws.rs.DELETE
Expand Down Expand Up @@ -514,7 +514,10 @@ interface UserPipelineResource {
sortType: PipelineSortType? = PipelineSortType.CREATE_TIME,
@Parameter(description = "排序规则", required = false)
@QueryParam("collation")
collation: PipelineCollation?
collation: PipelineCollation?,
@Parameter(description = "按流水线过滤", required = false)
@QueryParam("filterByPipelineName")
filterByPipelineName: String?
): Result<PipelineViewPipelinePage<PipelineInfo>>

@Operation(summary = "流水线重命名")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import com.tencent.devops.model.process.tables.records.TPipelineInfoRecord
import com.tencent.devops.process.engine.pojo.PipelineInfo
import com.tencent.devops.process.pojo.PipelineCollation
import com.tencent.devops.process.pojo.PipelineSortType
import java.time.LocalDateTime
import org.jooq.Condition
import org.jooq.DSLContext
import org.jooq.Field
Expand All @@ -47,6 +46,7 @@ import org.jooq.SortField
import org.jooq.impl.DSL
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Repository
import java.time.LocalDateTime

@Suppress("TooManyFunctions", "LongParameterList", "LargeClass")
@Repository
Expand Down Expand Up @@ -338,7 +338,8 @@ class PipelineInfoDao {
offset: Int? = null,
limit: Int? = null,
sortType: PipelineSortType,
collation: PipelineCollation
collation: PipelineCollation,
filterByPipelineName: String?
): Result<TPipelineInfoRecord>? {
with(T_PIPELINE_INFO) {
val conditions = mutableListOf<Condition>()
Expand All @@ -349,6 +350,9 @@ class PipelineInfoDao {
if (days != null) {
conditions.add(UPDATE_TIME.greaterOrEqual(LocalDateTime.now().minusDays(days)))
}
if (filterByPipelineName != null) {
conditions.add(PIPELINE_NAME.like("%$filterByPipelineName%"))
}
return dslContext
.selectFrom(this)
.where(conditions)
Expand All @@ -358,10 +362,12 @@ class PipelineInfoDao {
UPDATE_TIME,
collation
)

PipelineSortType.NAME -> transferOrder(
PIPELINE_NAME,
collation
)

else -> transferOrder(
CREATE_TIME,
collation
Expand Down Expand Up @@ -391,7 +397,8 @@ class PipelineInfoDao {
dslContext: DSLContext,
projectId: String,
deleteFlag: Boolean? = false,
days: Long? = null
days: Long? = null,
filterByPipelineName: String?
): Int {
with(T_PIPELINE_INFO) {
val conditions = mutableListOf<Condition>()
Expand All @@ -402,6 +409,9 @@ class PipelineInfoDao {
if (days != null) {
conditions.add(UPDATE_TIME.greaterOrEqual(LocalDateTime.now().minusDays(days)))
}
if (filterByPipelineName != null) {
conditions.add(PIPELINE_NAME.like("%$filterByPipelineName%"))
}
return dslContext
.selectCount().from(this)
.where(conditions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ import com.tencent.devops.process.utils.PIPELINE_SETTING_WAIT_QUEUE_TIME_MINUTE_
import com.tencent.devops.process.utils.PipelineVersionUtils
import com.tencent.devops.process.yaml.utils.NotifyTemplateUtils
import com.tencent.devops.project.api.service.ServiceAllocIdResource
import java.time.LocalDateTime
import java.util.concurrent.atomic.AtomicInteger
import javax.ws.rs.core.Response
import org.jooq.DSLContext
import org.jooq.impl.DSL
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
import java.time.LocalDateTime
import java.util.concurrent.atomic.AtomicInteger
import javax.ws.rs.core.Response

@Suppress(
"LongParameterList",
Expand Down Expand Up @@ -195,9 +195,9 @@ class PipelineRepositoryService constructor(
}
}
if (maxConRunningQueueSize != null && (
this.maxConRunningQueueSize!! <= PIPELINE_SETTING_MAX_QUEUE_SIZE_MIN ||
this.maxConRunningQueueSize!! > PIPELINE_SETTING_MAX_CON_QUEUE_SIZE_MAX
)
this.maxConRunningQueueSize!! <= PIPELINE_SETTING_MAX_QUEUE_SIZE_MIN ||
this.maxConRunningQueueSize!! > PIPELINE_SETTING_MAX_CON_QUEUE_SIZE_MAX
)
) {
throw InvalidParamException(
I18nUtil.getCodeLanMessage(ProcessMessageCode.MAXIMUM_NUMBER_CONCURRENCY_ILLEGAL),
Expand Down Expand Up @@ -407,11 +407,11 @@ class PipelineRepositoryService constructor(
)
}
val c = (
stage.containers.getOrNull(0)
?: throw ErrorCodeException(
errorCode = ProcessMessageCode.ERROR_PIPELINE_MODEL_NEED_JOB
)
) as TriggerContainer
stage.containers.getOrNull(0)
?: throw ErrorCodeException(
errorCode = ProcessMessageCode.ERROR_PIPELINE_MODEL_NEED_JOB
)
) as TriggerContainer

// #4518 各个容器ID的初始化
c.id = containerSeqId.get().toString()
Expand Down Expand Up @@ -589,9 +589,9 @@ class PipelineRepositoryService constructor(
if ((option.maxConcurrency ?: 0) > PIPELINE_MATRIX_CON_RUNNING_SIZE_MAX) {
throw InvalidParamException(
"matrix maxConcurrency number(${option.maxConcurrency}) " +
"exceed $PIPELINE_MATRIX_CON_RUNNING_SIZE_MAX /" +
"matrix maxConcurrency(${option.maxConcurrency}) " +
"is larger than $PIPELINE_MATRIX_CON_RUNNING_SIZE_MAX"
"exceed $PIPELINE_MATRIX_CON_RUNNING_SIZE_MAX /" +
"matrix maxConcurrency(${option.maxConcurrency}) " +
"is larger than $PIPELINE_MATRIX_CON_RUNNING_SIZE_MAX"
)
}
MatrixYamlCheckUtils.checkYaml(
Expand Down Expand Up @@ -912,7 +912,7 @@ class PipelineRepositoryService constructor(
}
logger.info(
"PROCESS|updateDraft|version=$version|versionName=$versionName" +
"operationLogType=$operationLogType|base=$realBaseVersion"
"operationLogType=$operationLogType|base=$realBaseVersion"
)
}
// 2 分支版本保存 —— 取当前流水线的最新VERSION+1,不关心其他草稿和正式版本
Expand Down Expand Up @@ -945,7 +945,7 @@ class PipelineRepositoryService constructor(
}
logger.info(
"PROCESS|updateBranch|version=$version|versionName=$versionName" +
"operationLogType=$operationLogType"
"operationLogType=$operationLogType"
)
}
// 3 通过分支发布 —— 将要通过分支发布的草稿直接更新为分支版本
Expand Down Expand Up @@ -980,7 +980,7 @@ class PipelineRepositoryService constructor(
}
logger.info(
"PROCESS|releaseByBranch|version=$version|versionName=$versionName" +
"operationLogType=$operationLogType"
"operationLogType=$operationLogType"
)
}
// 4 正式版本保存 —— 寻找当前草稿,存在草稿版本则报错,不存在则直接取最新VERSION+1同时更新INFO、RESOURCE表
Expand Down Expand Up @@ -1765,7 +1765,8 @@ class PipelineRepositoryService constructor(
offset: Int? = null,
limit: Int? = null,
sortType: PipelineSortType,
collation: PipelineCollation
collation: PipelineCollation,
filterByPipelineName: String?
): List<PipelineInfo> {
val result = pipelineInfoDao.listPipelinesByProject(
dslContext = dslContext,
Expand All @@ -1775,7 +1776,8 @@ class PipelineRepositoryService constructor(
offset = offset,
limit = limit,
sortType = sortType,
collation = collation
collation = collation,
filterByPipelineName = filterByPipelineName
)
val list = mutableListOf<PipelineInfo>()
result?.forEach {
Expand Down Expand Up @@ -1958,7 +1960,7 @@ class PipelineRepositoryService constructor(
) ?: ""
logger.info(
"PROCESS|updateSettingVersion|version=$version|" +
"versionNum=$versionNum|versionName=$versionName"
"versionNum=$versionNum|versionName=$versionName"
)
val newModel = releaseResource.model.copy(
name = savedSetting.pipelineName, desc = savedSetting.desc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import com.tencent.devops.common.pipeline.Model
import com.tencent.devops.common.pipeline.enums.ChannelCode
import com.tencent.devops.common.pipeline.enums.VersionStatus
import com.tencent.devops.common.pipeline.pojo.MatrixPipelineInfo
import com.tencent.devops.common.pipeline.pojo.PipelineModelAndSetting
import com.tencent.devops.common.pipeline.pojo.setting.PipelineRunLockType
import com.tencent.devops.common.pipeline.pojo.setting.PipelineSetting
import com.tencent.devops.common.pipeline.utils.MatrixYamlCheckUtils
import com.tencent.devops.common.web.RestResource
import com.tencent.devops.common.web.utils.I18nUtil
Expand All @@ -54,7 +57,9 @@ import com.tencent.devops.process.constant.ProcessMessageCode
import com.tencent.devops.process.constant.ProcessMessageCode.PIPELINE_LIST_LENGTH_LIMIT
import com.tencent.devops.process.engine.pojo.PipelineInfo
import com.tencent.devops.process.engine.pojo.PipelineVersionWithInfo
import com.tencent.devops.process.engine.service.PipelineRepositoryService.Companion.checkParam
import com.tencent.devops.process.engine.service.rule.PipelineRuleService
import com.tencent.devops.process.enums.OperationLogType
import com.tencent.devops.process.permission.PipelinePermissionService
import com.tencent.devops.process.pojo.Permission
import com.tencent.devops.process.pojo.Pipeline
Expand All @@ -73,11 +78,6 @@ import com.tencent.devops.process.pojo.classify.PipelineViewPipelinePage
import com.tencent.devops.process.pojo.pipeline.BatchDeletePipeline
import com.tencent.devops.process.pojo.pipeline.PipelineCount
import com.tencent.devops.process.pojo.pipeline.enums.PipelineRuleBusCodeEnum
import com.tencent.devops.common.pipeline.pojo.PipelineModelAndSetting
import com.tencent.devops.common.pipeline.pojo.setting.PipelineRunLockType
import com.tencent.devops.common.pipeline.pojo.setting.PipelineSetting
import com.tencent.devops.process.engine.service.PipelineRepositoryService.Companion.checkParam
import com.tencent.devops.process.enums.OperationLogType
import com.tencent.devops.process.service.PipelineInfoFacadeService
import com.tencent.devops.process.service.PipelineListFacadeService
import com.tencent.devops.process.service.PipelineRecentUseService
Expand Down Expand Up @@ -574,7 +574,8 @@ class UserPipelineResourceImpl @Autowired constructor(
page: Int?,
pageSize: Int?,
sortType: PipelineSortType?,
collation: PipelineCollation?
collation: PipelineCollation?,
filterByPipelineName: String?
): Result<PipelineViewPipelinePage<PipelineInfo>> {
checkParam(userId, projectId)
return Result(
Expand All @@ -584,7 +585,8 @@ class UserPipelineResourceImpl @Autowired constructor(
page = page,
pageSize = pageSize,
sortType = sortType ?: PipelineSortType.CREATE_TIME, ChannelCode.BS,
collation = collation ?: PipelineCollation.DEFAULT
collation = collation ?: PipelineCollation.DEFAULT,
filterByPipelineName = filterByPipelineName
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,8 @@ class PipelineListFacadeService @Autowired constructor(
dslContext = dslContext,
projectId = projectId,
deleteFlag = true,
days = deletedPipelineStoreDays.toLong()
days = deletedPipelineStoreDays.toLong(),
filterByPipelineName = null
)
return PipelineCount(totalCount, myFavoriteCount, myPipelineCount, recycleCount, recentUseCount)
}
Expand Down Expand Up @@ -1599,7 +1600,8 @@ class PipelineListFacadeService @Autowired constructor(
pageSize: Int?,
sortType: PipelineSortType,
channelCode: ChannelCode,
collation: PipelineCollation
collation: PipelineCollation,
filterByPipelineName: String?
): PipelineViewPipelinePage<PipelineInfo> {
val pageNotNull = page ?: 0
val pageSizeNotNull = pageSize ?: -1
Expand All @@ -1612,13 +1614,15 @@ class PipelineListFacadeService @Autowired constructor(
offset = slqLimit.offset,
limit = slqLimit.limit,
sortType = sortType,
collation = collation
collation = collation,
filterByPipelineName = filterByPipelineName
)
val count = pipelineInfoDao.countPipeline(
dslContext = dslContext,
projectId = projectId,
deleteFlag = true,
days = deletedPipelineStoreDays.toLong()
days = deletedPipelineStoreDays.toLong(),
filterByPipelineName = filterByPipelineName
)
// 加上流水线组
val pipelineViewNameMap =
Expand Down Expand Up @@ -1827,7 +1831,8 @@ class PipelineListFacadeService @Autowired constructor(
)
}
// 获取view信息
val pipelineViewNames = pipelineViewGroupService.getViewNameMap(projectId, mutableSetOf(pipelineId)).get(pipelineId)
val pipelineViewNames =
pipelineViewGroupService.getViewNameMap(projectId, mutableSetOf(pipelineId)).get(pipelineId)
val hasEditPermission = pipelinePermissionService.checkPipelinePermission(
userId = userId,
projectId = projectId,
Expand Down

0 comments on commit bab9bc1

Please sign in to comment.