Skip to content

Commit

Permalink
Merge pull request #11402 from yjieliang/bug-11400
Browse files Browse the repository at this point in the history
bug:组件latestFlag参数更新时组件所有版本修改者会全部更新为同一人 #11400
  • Loading branch information
mingshewhe authored Jan 10, 2025
2 parents b4eb2bf + 523b44c commit 34f1e7e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.tencent.devops.model.store.tables.TLabel
import com.tencent.devops.model.store.tables.TStoreMember
import com.tencent.devops.model.store.tables.TStoreStatisticsTotal
import com.tencent.devops.model.store.tables.records.TAtomRecord
import com.tencent.devops.store.common.utils.VersionUtils
import com.tencent.devops.store.pojo.atom.ApproveReq
import com.tencent.devops.store.pojo.atom.MarketAtomCreateRequest
import com.tencent.devops.store.pojo.atom.MarketAtomUpdateRequest
Expand All @@ -47,7 +48,6 @@ import com.tencent.devops.store.pojo.atom.enums.AtomStatusEnum
import com.tencent.devops.store.pojo.atom.enums.AtomTypeEnum
import com.tencent.devops.store.pojo.atom.enums.MarketAtomSortTypeEnum
import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum
import com.tencent.devops.store.common.utils.VersionUtils
import java.math.BigDecimal
import java.time.LocalDateTime
import org.jooq.Condition
Expand Down Expand Up @@ -732,14 +732,28 @@ class MarketAtomDao : AtomBaseDao() {
}
}

fun setupAtomLatestTestFlag(dslContext: DSLContext, userId: String, atomCode: String, atomId: String) {
fun setupAtomLatestTestFlagById(
dslContext: DSLContext,
userId: String,
atomId: String,
latestFlag: Boolean
) {
with(TAtom.T_ATOM) {
dslContext.update(this)
.set(
LATEST_TEST_FLAG,
DSL.case_().`when`(ID.eq(atomId), true).otherwise(false)
)
.set(LATEST_TEST_FLAG, latestFlag)
.set(MODIFIER, userId)
.where(ID.eq(atomId))
.execute()
}
}

fun resetAtomLatestTestFlagByCode(
dslContext: DSLContext,
atomCode: String
) {
with(TAtom.T_ATOM) {
dslContext.update(this)
.set(LATEST_TEST_FLAG, false)
.where(ATOM_CODE.eq(atomCode))
.execute()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,6 @@ interface AtomReleaseService {
* 结束分支版本测试
*/
fun endBranchVersionTest(userId: String, atomCode: String, branch: String): Result<Boolean>

fun updateAtomLatestTestFlag(userId: String, atomCode: String, atomId: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,19 @@ class AtomHandleBuildResultServiceImpl @Autowired constructor(
marketAtomService.setAtomBuildStatusByAtomCode(
atomCode = atomCode,
version = version,
userId = storeBuildResultRequest.userId,
userId = atomRecord.modifier,
atomStatus = atomStatus,
msg = null
)
if (atomStatus == AtomStatusEnum.TESTING) {

RedisLock(
redisOperation,
"$STORE_LATEST_TEST_FLAG_KEY_PREFIX:$atomCode",
60L
).use { redisLock ->
redisLock.lock()
marketAtomDao.setupAtomLatestTestFlag(
dslContext = dslContext,
userId = storeBuildResultRequest.userId,
atomCode = atomCode,
atomId = atomId
)
atomReleaseService.updateAtomLatestTestFlag(atomRecord.modifier, atomCode, atomId)
}
// 插件errorCodes.json文件数据入库
atomReleaseService.syncAtomErrorCodeConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1458,13 +1458,30 @@ abstract class AtomReleaseServiceImpl @Autowired constructor() : AtomReleaseServ
redisLock.lock()
if (marketAtomDao.isAtomLatestTestVersion(dslContext, atomId) > 0) {
val latestTestVersionId = marketAtomDao.queryAtomLatestTestVersionId(dslContext, atomCode, atomId)
marketAtomDao.setupAtomLatestTestFlag(
dslContext = dslContext,
userId = userId,
atomCode = atomCode,
atomId = latestTestVersionId ?: ""
)
latestTestVersionId?.let {
updateAtomLatestTestFlag(
userId = userId,
atomCode = atomCode,
atomId = it
)
}
}
}
}

override fun updateAtomLatestTestFlag(userId: String, atomCode: String, atomId: String) {
dslContext.transaction { configuration ->
val transactionContext = DSL.using(configuration)
marketAtomDao.resetAtomLatestTestFlagByCode(
dslContext = transactionContext,
atomCode = atomCode
)
marketAtomDao.setupAtomLatestTestFlagById(
dslContext = transactionContext,
atomId = atomId,
userId = userId,
latestFlag = true
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import com.tencent.devops.store.pojo.atom.MarketAtomCreateRequest
import com.tencent.devops.store.pojo.atom.MarketAtomUpdateRequest
import com.tencent.devops.store.pojo.atom.enums.AtomStatusEnum
import com.tencent.devops.store.pojo.common.STORE_LATEST_TEST_FLAG_KEY_PREFIX
import com.tencent.devops.store.pojo.common.publication.ReleaseProcessItem
import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum
import com.tencent.devops.store.pojo.common.publication.ReleaseProcessItem
import org.jooq.DSLContext
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
Expand Down Expand Up @@ -100,12 +100,7 @@ class SampleAtomReleaseServiceImpl : SampleAtomReleaseService, AtomReleaseServic
60L
).use { redisLock ->
redisLock.lock()
marketAtomDao.setupAtomLatestTestFlag(
dslContext = dslContext,
userId = userId,
atomCode = record.atomCode,
atomId = atomId
)
updateAtomLatestTestFlag(userId, record.atomCode, atomId)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import com.tencent.devops.common.api.constant.CommonMessageCode
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.pipeline.enums.BuildStatus
import com.tencent.devops.common.web.utils.I18nUtil
import com.tencent.devops.store.common.service.AbstractStoreHandleBuildResultService
import com.tencent.devops.store.image.dao.ImageDao
import com.tencent.devops.store.image.service.MarketImageService
import com.tencent.devops.store.pojo.common.publication.StoreBuildResultRequest
import com.tencent.devops.store.pojo.image.enums.ImageStatusEnum
import com.tencent.devops.store.common.service.AbstractStoreHandleBuildResultService
import com.tencent.devops.store.image.service.MarketImageService
import org.jooq.DSLContext
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
Expand Down Expand Up @@ -73,7 +73,7 @@ class ImageHandleBuildResultService @Autowired constructor(
}
marketImageService.setImageBuildStatusByImageId(
imageId = imageId,
userId = storeBuildResultRequest.userId,
userId = imageRecord.modifier,
imageStatus = imageStatus,
msg = null
)
Expand Down

0 comments on commit 34f1e7e

Please sign in to comment.