Skip to content

Commit

Permalink
fix: 编译加速资源上报统计数据异常 #269
Browse files Browse the repository at this point in the history
  • Loading branch information
eazence committed Sep 10, 2024
1 parent 1238b4a commit 66c8f69
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ interface BaseDataRepository : MongoRepository<BaseDataEntity, String> {
* 根据参数标识代码查询
*/
fun findFirstByParamCode(paramCode: String): BaseDataEntity?

/**
* 根据参数标识代码list查询
*/
fun findByParamCodeIn(paramCodeList: List<String>): List<BaseDataEntity>
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import com.tencent.devops.common.api.exception.code.TURBO_PARAM_INVALID
import com.tencent.devops.common.api.pojo.Page
import com.tencent.devops.common.util.JsonUtil
import com.tencent.devops.common.util.MathUtil
import com.tencent.devops.common.util.constants.BASE_EXCLUDED_PLAN_ID_LIST
import com.tencent.devops.common.util.constants.BASE_EXCLUDED_COMMON_PLAN_ID
import com.tencent.devops.common.util.constants.BASE_EXCLUDED_PLAN_ID_LIST_FOR_DEV_CLOUD
import com.tencent.devops.common.util.constants.BASE_EXCLUDED_PROJECT_ID_LIST
import com.tencent.devops.turbo.config.TodCostProperties
import com.tencent.devops.turbo.dao.mongotemplate.TbsDaySummaryDao
Expand Down Expand Up @@ -50,8 +51,9 @@ class ProjectResourcesService @Autowired constructor(
val pageSizeNum = pageSize?.coerceAtMost(10000) ?: 100

// 获取需要过滤掉的方案id集合
val baseDataEntity = baseDataRepository.findFirstByParamCode(BASE_EXCLUDED_PLAN_ID_LIST)
val filterPlanIds = baseDataEntity?.paramValue?.split(",")?.toSet() ?: emptySet()
val baseDataEntityList = baseDataRepository.findByParamCodeIn(listOf(BASE_EXCLUDED_PLAN_ID_LIST_FOR_DEV_CLOUD,
BASE_EXCLUDED_COMMON_PLAN_ID))
val filterPlanIds = baseDataEntityList.flatMap { it.paramValue.split(",") }.toSet() ?: emptySet()

// 获取需要过滤掉的项目id集合
val projectExcludedEntity = baseDataRepository.findFirstByParamCode(BASE_EXCLUDED_PROJECT_ID_LIST)
Expand Down Expand Up @@ -120,7 +122,7 @@ class ProjectResourcesService @Autowired constructor(
val end = endDate?.let { LocalDate.parse(it) } ?: today.withDayOfMonth(14)
this.checkDatesInMonth(month, start, end)

val filterPlanIds = getFilterIds(BASE_EXCLUDED_PLAN_ID_LIST)
val filterPlanIds = getFilterIds(BASE_EXCLUDED_COMMON_PLAN_ID)
val filterProjectIds = getFilterIds(BASE_EXCLUDED_PROJECT_ID_LIST)
val properties = SpringContextHolder.getBean<TodCostProperties>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ const val SYSTEM_ADMIN = "Turbo"
const val NO_ADMIN_MEMBER_MESSAGE = "无权限,请先加入项目!"

/**
* 统计数据需排除的plan id
* 统计数据需排除的plan id(DevCloud专用统计排除,服务计费不需要过滤掉)
* 微信和王者的机器资源是他们自己管理,DevCloud无需计费,咱们内部计费需要纳入统计
*/
const val BASE_EXCLUDED_PLAN_ID_LIST = "EXCLUDED_PLAN_ID_LIST"
const val BASE_EXCLUDED_PLAN_ID_LIST_FOR_DEV_CLOUD = "EXCLUDED_PLAN_ID_LIST"

/**
* 统计数据需排除的project id
*/
const val BASE_EXCLUDED_PROJECT_ID_LIST = "EXCLUDED_PROJECT_ID_LIST"

/**
* 内部测试的方案,服务计费时需要过滤掉
*/
const val BASE_EXCLUDED_COMMON_PLAN_ID = "EXCLUDED_COMMON_PLAN_ID_LIST"

0 comments on commit 66c8f69

Please sign in to comment.