test
youys 3 years ago
parent 2f8921fd26
commit 3d35d48c95

@ -31,7 +31,9 @@ public class QualityInspectController {
/**
*
* @param qualityInspectVO
* @param language
* @param homeworkId id
* @param userDatas
* @return
*/
@RequestMapping(value = "qualityInspect", method = RequestMethod.POST)

@ -1,5 +1,6 @@
package net.educoder.ecsonar.dao;
import net.educoder.ecsonar.model.Metrics;
import net.educoder.ecsonar.model.Project;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -26,4 +27,25 @@ public interface ProjectDao {
@Select("SELECT count(*) FROM issues where project_uuid=#{uuid} and " +
"status='OPEN' and issue_type=#{issue_type} and severity=#{severity}")
int getIndicator(@Param("uuid") String uuid, @Param("issue_type") int issue_type, @Param("severity") String severity);
@Select("select " +
"(select COALESCE(value,0) complexity from project_measures where component_uuid = #{projectUuid} and metric_id = 19 order by id desc limit 1)," +
"(select COALESCE(value,0) lines from project_measures where component_uuid = #{projectUuid} and metric_id = 1 order by id desc limit 1)," +
"(SELECT COALESCE(count(*),0) block_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='BLOCKER'), " +
"(SELECT COALESCE(count(*),0) critical_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='CRITICAL')," +
"(SELECT COALESCE(count(*),0) major_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='MAJOR')," +
"(SELECT COALESCE(count(*),0) minor_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='MINOR')," +
"(select text_value code_smells from project_measures where component_uuid = #{projectUuid} and metric_id = 80 order by id desc limit 1)," +
"(SELECT COALESCE(count(*),0) block_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='BLOCKER'), " +
"(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) 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 = 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) 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) 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 = 93 order by id desc limit 1)")
Metrics selectMetricsByProjectUuid(String projectUuid);
}

@ -3,7 +3,7 @@ package net.educoder.ecsonar.model;
public class Metrics {
// 复杂度
private String complexity;
private Float complexity;
private int lines;
@ -31,10 +31,10 @@ public class Metrics {
public String getComplexity() {
return complexity;
return complexity+"";
}
public void setComplexity(String complexity) {
public void setComplexity(Float complexity) {
this.complexity = complexity;
}

@ -167,8 +167,8 @@ public class QualityInspectService {
if (taskInfo.getStatus() == 0 && completed == 1) {
taskInfoDao.updateTaskInfoStatus(taskInfo.getId(), 1);
// 并且删除文件 /tmp/taskId/* /tmp/homeworkId/*
String command = String.format("rm -rf /tmp/%s/* && rm -rf /tmp/%s/*", taskId, taskInfo.getHomeworkId());
// 并且删除文件 /tmp/$taskId /tmp/homeworkId/*
String command = String.format("rm -rf /tmp/%s && rm -rf /tmp/%s/*", taskId, taskInfo.getHomeworkId());
SystemUtil.executeAndGetExitStatus(command);
}

@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
@Service
public class ReportService {
@ -35,31 +34,14 @@ public class ReportService {
}
String uuid = project.getProject_uuid();
Metrics metrics = new Metrics();
metrics.setComplexity(getComplexity(uuid));
metrics.setLines(getLines(uuid));
metrics.setBlock_bugs(getBlockBugs(uuid));
metrics.setBlock_code_smells(getBlockCodeSmells(uuid));
metrics.setBlock_violations(getBlockViolations(uuid));
metrics.setCritical_bugs(getCriticalBugs(uuid));
metrics.setCritical_code_smells(getCriticalCodeSmells(uuid));
metrics.setCritical_violations(getCriticalViolations(uuid));
metrics.setMajor_bugs(getMajorBugs(uuid));
metrics.setMajor_code_smells(getMajorCodeSmells(uuid));
metrics.setMajor_violations(getMajorViolations(uuid));
metrics.setMinor_bugs(getMinorBugs(uuid));
metrics.setMinor_code_smells(getMinorCodeSmells(uuid));
metrics.setMinor_violations(getMinorViolations(uuid));
metrics.setBugs(getBugs(uuid));
metrics.setViolations(getViolations(uuid));
metrics.setCode_smells(getCodeSmells(uuid));
Metrics metrics = projectDao.selectMetricsByProjectUuid(uuid);
return metrics;
}
public Metrics getDefault(){
Metrics metrics = new Metrics();
metrics.setComplexity("0");
metrics.setComplexity(0f);
metrics.setLines(0);
metrics.setBlock_bugs(0);
metrics.setBlock_code_smells(0);
@ -276,4 +258,7 @@ public class ReportService {
//80
return projectDao.getLevel(uuid, 80);
}
}

Loading…
Cancel
Save