Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 编译加速资源上报统计数据异常 #269 #270

Merged
merged 5 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class TbsDaySummaryDao @Autowired constructor(

val criteria = Criteria.where("day").gte(startDate).lte(endDate)
.and("user").`is`(null)
.and("total_time_with_cpu").gt(0)
.and("engine_code").ne("disttask-ue4")
.apply { if (filterPlanIdNin.isNotEmpty()) and("plan_id").nin(filterPlanIdNin) }
.apply { if (filterProjectIdNin.isNotEmpty()) and("project_id").nin(filterProjectIdNin) }
Expand Down Expand Up @@ -112,6 +113,7 @@ class TbsDaySummaryDao @Autowired constructor(
logger.info("findByDayForUE startDate: $startDate, endDate: $endDate, filterPlanIdNin: $filterPlanIdNin")
val criteria = Criteria.where("day").gte(startDate).lte(endDate)
.and("user").ne(null)
.and("total_time_with_cpu").gt(0)
.and("engine_code").`is`("disttask-ue4")
.apply {
if (filterPlanIdNin.isNotEmpty()) and("plan_id").nin(filterPlanIdNin)
Expand Down
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
@@ -1,7 +1,7 @@
dependencies {
api("org.quartz-scheduler:quartz")
api("org.quartz-scheduler:quartz-jobs")
api("com.novemberain:quartz-mongodb:2.2.0-rc2")
api("io.fluidsonic.mirror:quartz-mongodb:2.2.0-rc2")
api("org.springframework.boot:spring-boot-starter")
api("org.springframework:spring-context-support")
api("org.springframework:spring-tx")
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"
Loading