Skip to content

Commit

Permalink
fix: 当业务下有大量的执行作业,加载 web 页面首页的时候会触发DB慢查询 #2228
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Jul 14, 2023
1 parent 6d1daf6 commit 56fc950
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
import com.tencent.bk.job.common.annotation.InternalAPI;
import com.tencent.bk.job.common.model.InternalResponse;
import com.tencent.bk.job.common.statistics.model.dto.StatisticsDTO;
import com.tencent.bk.job.execute.model.inner.request.ServiceTriggerStatisticsRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

Expand Down Expand Up @@ -72,4 +75,11 @@ InternalResponse<StatisticsDTO> getStatistics(
@ApiParam(value = "统计日期(yyyy-MM-dd)", required = true)
@RequestParam(value = "dateStr", required = true) String dateStr
);

@ApiOperation(value = "触发指定时间的数据统计", produces = "application/json")
@PostMapping("/service/metrics/statistics/trigger")
InternalResponse<Boolean> triggerStatistics(
@ApiParam(value = "统计日期(yyyy-MM-dd)", required = false)
@RequestBody ServiceTriggerStatisticsRequest request
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.tencent.bk.job.common.model.InternalResponse;
import com.tencent.bk.job.common.statistics.model.dto.StatisticsDTO;
import com.tencent.bk.job.execute.model.inner.request.ServiceTriggerStatisticsRequest;
import com.tencent.bk.job.execute.service.TaskInstanceService;
import com.tencent.bk.job.execute.statistics.StatisticsService;
import io.micrometer.core.annotation.Timed;
Expand Down Expand Up @@ -67,4 +68,9 @@ public InternalResponse<StatisticsDTO> getStatistics(Long appId, String resource
return InternalResponse.buildSuccessResp(statisticsService.getStatistics(appId, resource, dimension,
dimensionValue, dateStr));
}

@Override
public InternalResponse<Boolean> triggerStatistics(ServiceTriggerStatisticsRequest request) {
return InternalResponse.buildSuccessResp(statisticsService.triggerStatistics(request.getDateList()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ public Boolean triggerStatistics(List<String> dateList) {
updateStartJobStatistics(taskInstance);
}
offset += limit;
Thread.sleep(2000);
} while (taskInstanceIds.size() == limit);
}
}
Expand Down

0 comments on commit 56fc950

Please sign in to comment.