master
youys 2 years ago
parent a3acd04f2c
commit e3c2405364

@ -40,7 +40,7 @@ public interface IssuesDao {
* @param issueType * @param issueType
* @return * @return
*/ */
DegreeDTO queryDegree(String projectUuid, Integer issueType); DegreeDTO queryDegree(String projectUuid, Integer issueType, Integer metricId);
/** /**

@ -43,12 +43,12 @@ public interface ProjectDao {
"(SELECT COALESCE(count(*),0) critical_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='CRITICAL')," + "(SELECT COALESCE(count(*),0) critical_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='CRITICAL')," +
"(SELECT COALESCE(count(*),0) major_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='MAJOR')," + "(SELECT COALESCE(count(*),0) major_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='MAJOR')," +
"(SELECT COALESCE(count(*),0) minor_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='MINOR')," + "(SELECT COALESCE(count(*),0) minor_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='MINOR')," +
"(select text_value bugs from project_measures where component_uuid = #{projectUuid} and metric_id = 80 order by id desc limit 1)," + "(select text_value bugs from project_measures where component_uuid = #{projectUuid} and metric_id = 89 order by id desc limit 1)," +
"(SELECT COALESCE(count(*),0) block_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='BLOCKER'), " + "(SELECT COALESCE(count(*),0) block_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='BLOCKER'), " +
"(SELECT COALESCE(count(*),0) critical_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='CRITICAL')," + "(SELECT COALESCE(count(*),0) critical_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='CRITICAL')," +
"(SELECT COALESCE(count(*),0) major_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='MAJOR')," + "(SELECT COALESCE(count(*),0) major_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='MAJOR')," +
"(SELECT COALESCE(count(*),0) minor_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='MINOR')," + "(SELECT COALESCE(count(*),0) minor_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='MINOR')," +
"(select text_value violations from project_measures where component_uuid = #{projectUuid} and metric_id = 80 order by id desc limit 1)") "(select text_value violations from project_measures where component_uuid = #{projectUuid} and metric_id = 93 order by id desc limit 1)")
Metrics selectMetricsByProjectUuid(String projectUuid); Metrics selectMetricsByProjectUuid(String projectUuid);

@ -8,15 +8,17 @@ package net.educoder.ecsonar.enums;
*/ */
public enum AnalyseTypeEnum { public enum AnalyseTypeEnum {
CodeSmell(1), CodeSmell(1,80),
BUG(2), BUG(2, 89),
Vulnerability(3); Vulnerability(3,93);
private Integer type; private Integer type;
private Integer metricId;
AnalyseTypeEnum(Integer type) { AnalyseTypeEnum(Integer type, Integer metricId) {
this.type = type; this.type = type;
this.metricId = metricId;
} }
@ -24,6 +26,10 @@ public enum AnalyseTypeEnum {
return type; return type;
} }
public Integer getMetricId() {
return metricId;
}
public static AnalyseTypeEnum getAnalyseTypeEnum(Integer type) { public static AnalyseTypeEnum getAnalyseTypeEnum(Integer type) {
for (AnalyseTypeEnum analyseType : values()) { for (AnalyseTypeEnum analyseType : values()) {
if (analyseType.type.equals(type)) { if (analyseType.type.equals(type)) {

@ -240,9 +240,9 @@ public class QualityInspectService {
throw new BusinessException(-1, String.format("找不到分析记录homeworkId:%s,studentNo:%s", analyseDetailVO.getHomeworkId(), analyseDetailVO.getStudentNo())); throw new BusinessException(-1, String.format("找不到分析记录homeworkId:%s,studentNo:%s", analyseDetailVO.getHomeworkId(), analyseDetailVO.getStudentNo()));
} }
DegreeDTO codeSmall = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.CodeSmell.getType()); DegreeDTO codeSmall = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.CodeSmell.getType(), AnalyseTypeEnum.CodeSmell.getMetricId());
DegreeDTO bug = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.BUG.getType()); DegreeDTO bug = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.BUG.getType(), AnalyseTypeEnum.BUG.getMetricId());
DegreeDTO vulnerability = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.Vulnerability.getType()); DegreeDTO vulnerability = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.Vulnerability.getType(), AnalyseTypeEnum.Vulnerability.getMetricId());
AnalyseDetailDTO analyseDetail = new AnalyseDetailDTO(); AnalyseDetailDTO analyseDetail = new AnalyseDetailDTO();
analyseDetail.setBug(bug == null ? new DegreeDTO() : bug); analyseDetail.setBug(bug == null ? new DegreeDTO() : bug);
@ -317,17 +317,17 @@ public class QualityInspectService {
problemAnalysisDTO.setTitle(rule.getName()); problemAnalysisDTO.setTitle(rule.getName());
problemAnalysisDTO.setExample(example); problemAnalysisDTO.setExample(example);
problemAnalysisDTO.setLanguage(rule.getLanguage()); problemAnalysisDTO.setLanguage("py".equalsIgnoreCase(rule.getLanguage()) ? "python" : rule.getLanguage());
problemAnalysisDTO.setConstantIssue(rule.getDefRemediationBaseEffort()); problemAnalysisDTO.setConstantIssue(rule.getDefRemediationBaseEffort());
if (StringUtils.isBlank(rule.getTags())) { if (StringUtils.isBlank(rule.getTags())) {
problemAnalysisDTO.setTags(new ArrayList<>()); problemAnalysisDTO.setTags(new ArrayList<>());
}else{ } else {
problemAnalysisDTO.setTags(Arrays.asList(rule.getTags().split(","))); problemAnalysisDTO.setTags(Arrays.asList(rule.getTags().split(",")));
} }
problemAnalysisDTO.setCreateTime(DateUtil.formatDateTime(new Date(rule.getCreateTime()))); problemAnalysisDTO.setCreateTime(DateUtil.formatDateTime(new Date(rule.getCreateTime())));
}else{ } else {
problemAnalysisDTO.setTitle(""); problemAnalysisDTO.setTitle("");
problemAnalysisDTO.setExample(""); problemAnalysisDTO.setExample("");
problemAnalysisDTO.setLanguage(""); problemAnalysisDTO.setLanguage("");

@ -42,12 +42,12 @@
<select id="queryDegree" resultType="net.educoder.ecsonar.model.dto.DegreeDTO"> <select id="queryDegree" resultType="net.educoder.ecsonar.model.dto.DegreeDTO">
select select
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and status='OPEN') total, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and status='OPEN' and severity != 'INFO') total,
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MAJOR' and status='OPEN') major, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MAJOR' and status='OPEN') major,
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MINOR' and status='OPEN') minor, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MINOR' and status='OPEN') minor,
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'BLOCKER' and status='OPEN') blocker, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'BLOCKER' and status='OPEN') blocker,
(select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'CRITICAL' and status='OPEN') critical, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'CRITICAL' and status='OPEN') critical,
(select text_value from project_measures i where component_uuid =#{projectUuid} and metric_id = 80 order by id desc limit 1) levelStr (select text_value from project_measures i where component_uuid =#{projectUuid} and metric_id = #{metricId} order by id desc limit 1) levelStr
</select> </select>

Loading…
Cancel
Save