|
@@ -1,12 +1,16 @@
|
|
|
package edu.nju.service;
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.google.common.cache.Cache;
|
|
|
import com.google.common.cache.CacheBuilder;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import edu.nju.algorithm.progress.BugForProgress;
|
|
|
+import edu.nju.algorithm.progress.TaskClosePrediction;
|
|
|
import edu.nju.dao.*;
|
|
|
import edu.nju.entities.*;
|
|
|
import edu.nju.model.*;
|
|
@@ -1061,6 +1065,74 @@ public class AnalyzeService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ private Double crowdTestProgress(String caseId,String taskId) throws ParseException {
|
|
|
+ SimpleDateFormat formatLine = new SimpleDateFormat ("yyyy/MM/dd HH:mm");
|
|
|
+ SimpleDateFormat formatCon = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
|
|
|
+ List<BugForProgress> bugForProgressList=new ArrayList<>();
|
|
|
+ String case_take_id=caseId+"-"+taskId;
|
|
|
+ List<Report> reportList = reportDao.findByCaseTakeId(case_take_id);
|
|
|
+ for (Report report : reportList) {
|
|
|
+ String reportId = report.getId();
|
|
|
+ List<TestCase> testCaseList = testCaseDao.findByReport(reportId);
|
|
|
+ for (TestCase testCase : testCaseList) {
|
|
|
+ String testCaseId = testCase.getId();
|
|
|
+ List<String> bugIdList = ctbdao.findById(testCaseId);
|
|
|
+ for (String bugId : bugIdList) {
|
|
|
+ Bug bug = bdao.findByid(bugId);
|
|
|
+ if (bug != null) {
|
|
|
+ BugForProgress bugForProgress = new BugForProgress();
|
|
|
+ bugForProgress.setId(bugId);
|
|
|
+ bugForProgress.setTestCaseId(testCaseId);
|
|
|
+ bugForProgress.setTestCaseName(testCase.getName());
|
|
|
+ bugForProgress.setUserId(report.getWorker_id());
|
|
|
+ //bug基本属性
|
|
|
+ bugForProgress.setSeverity(TransUtil.severityTransFromInt(bug.getSeverity()));
|
|
|
+ bugForProgress.setBugPage(bug.getBug_page());
|
|
|
+ bugForProgress.setTitle(bug.getTitle());
|
|
|
+ bugForProgress.setDescription(bug.getDescription());
|
|
|
+ String time = TransUtil.formatTimeMillis(bug.getCreate_time_millis());
|
|
|
+ time = transferString(time);
|
|
|
+ Date submitTime = null;
|
|
|
+ if ( time.contains( "-")) {
|
|
|
+ submitTime = formatCon.parse( time );
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ submitTime = formatLine.parse( time );
|
|
|
+ }
|
|
|
+ bugForProgress.setBugCreateTime(submitTime);
|
|
|
+ bugForProgressList.add(bugForProgress);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bugForProgressList.sort(new Comparator<BugForProgress>() {
|
|
|
+ @Override
|
|
|
+ public int compare(BugForProgress o1, BugForProgress o2) {
|
|
|
+ Date d1 = o1.getBugCreateTime();
|
|
|
+ Date d2 = o2.getBugCreateTime();
|
|
|
+ if (d1.before(d2)) {
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ TaskClosePrediction closePrediction = new TaskClosePrediction();
|
|
|
+ Double completeRatio = closePrediction.determineTaskProgressStatus(bugForProgressList);
|
|
|
+ completeRatio = completeRatio.intValue() * 1.0;
|
|
|
+ return completeRatio;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private String transferString ( String str ){
|
|
|
+ String result = str;
|
|
|
+ result = result.replaceAll( "\r\n", " " );
|
|
|
+ result = result.replaceAll( "\r", " " );
|
|
|
+ result = result.replaceAll( "\n", " " );
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|