|
|
@@ -1,17 +1,16 @@
|
|
|
package com.seecoder.dataanalysis.analysis.impl;
|
|
|
|
|
|
import com.seecoder.dataanalysis.analysis.DevcloudDataAnalysisService;
|
|
|
-import com.seecoder.dataanalysis.data.dao.devcloud.DevcloudInfoDao;
|
|
|
-import com.seecoder.dataanalysis.data.dao.devcloud.DevcloudProjectDao;
|
|
|
-import com.seecoder.dataanalysis.data.dao.devcloud.DevcloudUserDao;
|
|
|
-import com.seecoder.dataanalysis.data.dao.devcloud.ProjectRelateDao;
|
|
|
+import com.seecoder.dataanalysis.data.dao.devcloud.*;
|
|
|
+import com.seecoder.dataanalysis.data.dao.eval.UserDao;
|
|
|
import com.seecoder.dataanalysis.data.entity.devcloud.*;
|
|
|
-import com.seecoder.dataanalysis.data.entity.devcloud.display.FormatGroup;
|
|
|
-import com.seecoder.dataanalysis.data.entity.devcloud.display.FormatStudent;
|
|
|
+import com.seecoder.dataanalysis.data.entity.devcloud.display.*;
|
|
|
+import com.seecoder.dataanalysis.data.entity.eval.User;
|
|
|
import com.seecoder.dataanalysis.vo.devcloud.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
@@ -31,6 +30,10 @@ public class DevcloudDataAnalysisServiceImpl implements DevcloudDataAnalysisServ
|
|
|
private DevcloudUserDao devcloudUserDao;
|
|
|
@Autowired
|
|
|
private ProjectRelateDao projectRelateDao;
|
|
|
+ @Autowired
|
|
|
+ private UserDao userDao;
|
|
|
+ @Autowired
|
|
|
+ private ProjectDao projectDao;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -273,8 +276,6 @@ public class DevcloudDataAnalysisServiceImpl implements DevcloudDataAnalysisServ
|
|
|
if(!result.isPresent()){
|
|
|
devcloudProject = new DevcloudProject();
|
|
|
devcloudProject.setProjectId(projectId);
|
|
|
- List<Integer> members = new ArrayList<>();
|
|
|
- devcloudProject.setUserIds(members);
|
|
|
devcloudProjectDao.save(devcloudProject);
|
|
|
}else {
|
|
|
devcloudProject = devcloudProjectDao.findById(projectId).get();
|
|
|
@@ -297,8 +298,6 @@ public class DevcloudDataAnalysisServiceImpl implements DevcloudDataAnalysisServ
|
|
|
if(!result1.isPresent()){
|
|
|
devcloudUser = new DevcloudUser();
|
|
|
devcloudUser.setUserId(userId);
|
|
|
- List<Integer> projects = new ArrayList<>();
|
|
|
- devcloudUser.setProjectIds(projects);
|
|
|
}else {
|
|
|
devcloudUser = devcloudUserDao.findById(userId).get();
|
|
|
}
|
|
|
@@ -337,12 +336,279 @@ public class DevcloudDataAnalysisServiceImpl implements DevcloudDataAnalysisServ
|
|
|
|
|
|
@Override
|
|
|
public FormatStudent getStudentAnalysis(Integer user_id){
|
|
|
- return null;
|
|
|
+ FormatStudent formatStudent = new FormatStudent();
|
|
|
+ User user = userDao.findByUserId(user_id);
|
|
|
+ DevcloudUser devcloudUser;
|
|
|
+
|
|
|
+ Optional<DevcloudUser> result = devcloudUserDao.findById(user_id);
|
|
|
+ if(!result.isPresent()){
|
|
|
+ devcloudUser = devcloudUserDao.findById(user_id).get();
|
|
|
+ }else {
|
|
|
+ System.out.println("没有查找到学生id");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //放入展示数据
|
|
|
+ formatStudent.setUserId(user_id);
|
|
|
+ formatStudent.setName(user.getUsername());
|
|
|
+ formatStudent.setEmail(user.getEmail());
|
|
|
+
|
|
|
+ //根据用户id找到和该用户关联的所有项目id
|
|
|
+ List<Integer> projectList = devcloudUserDao.findById(user_id).get().getProjectIds();
|
|
|
+ List<Project> projects = new ArrayList<>();
|
|
|
+ for(int i=0;i<projectList.size();i++){
|
|
|
+ projects.add(projectDao.findById(projectList.get(i)).get());
|
|
|
+ }
|
|
|
+ //放入个人包含的所有项目信息
|
|
|
+ formatStudent.setProjects(projects);
|
|
|
+
|
|
|
+ //放入个人Commit信息,测试信息,流水线信息
|
|
|
+ Commit commit = new Commit();
|
|
|
+ Test test = new Test();
|
|
|
+ Pipeline pipeline = new Pipeline();
|
|
|
+
|
|
|
+ Integer commit_times=0,valid_commit_time=0,buglist_commit=0,feature_commit=0;
|
|
|
+ List<String> commit_msg_overview = new ArrayList<>();
|
|
|
+ Integer test_success=0,test_failure=0,test_times=0,test_concurrency_count=0;
|
|
|
+ Integer pipeline_deploy=0,pipeline_pass=0,pipeline_failure=0;
|
|
|
+ //遍历所有相关项目
|
|
|
+ for(int i=0;i<projectList.size();i++){
|
|
|
+ Integer projectId = projectList.get(i);
|
|
|
+ DevcloudInfo devcloudInfo = devcloudInfoDao.findById(projectId).get();
|
|
|
+ //遍历devInfo中的commit信息
|
|
|
+ List<CommitInfo> commitInfos = devcloudInfo.getCommitList();
|
|
|
+ for(CommitInfo commitInfo : commitInfos){
|
|
|
+ if(commitInfo.getUserId().equals(user_id)){
|
|
|
+ commit_times++;
|
|
|
+ commit_msg_overview.add(commitInfo.getMessage());
|
|
|
+ //如果是需求的commit
|
|
|
+ if(commitInfo.getType().toLowerCase().equals("tree_id")){
|
|
|
+ feature_commit++;
|
|
|
+ }
|
|
|
+ //如果是bug_list的commit
|
|
|
+ if(commitInfo.getType().toLowerCase().equals("bug_id")){
|
|
|
+ buglist_commit++;
|
|
|
+ }
|
|
|
+ //判断是否是有效的commit
|
|
|
+ if(commitInfo.getMessage().startsWith("feat:")||commitInfo.getMessage().startsWith("fix:")){
|
|
|
+ valid_commit_time++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //遍历devInfo中的test信息
|
|
|
+ List<TestInfo> testInfos = devcloudInfo.getTestList();
|
|
|
+ for(TestInfo testInfo : testInfos){
|
|
|
+ if(testInfo.getUserId().equals(user_id)){
|
|
|
+ test_times++;
|
|
|
+ test_success += testInfo.getSuccess();
|
|
|
+ test_failure += testInfo.getFailure();
|
|
|
+ test_concurrency_count += testInfo.getSuccess();
|
|
|
+ test_concurrency_count += testInfo.getFailure();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //遍历devInfo中的pipeline信息
|
|
|
+ List<PipelineInfo> pipelineInfos = devcloudInfo.getPipelineList();
|
|
|
+ for(PipelineInfo pipelineInfo : pipelineInfos){
|
|
|
+ //遍历每个流水线中的部署记录
|
|
|
+ List<RecordInfo> recordInfos = pipelineInfo.getRecordList();
|
|
|
+ for(RecordInfo recordInfo : recordInfos){
|
|
|
+ if(recordInfo.getUserId().equals(user_id)){
|
|
|
+ pipeline_deploy++;
|
|
|
+ if(recordInfo.getResult().equals("部署成功")){
|
|
|
+ pipeline_pass++;
|
|
|
+ }
|
|
|
+ if(recordInfo.getResult().equals("部署失败")){
|
|
|
+ pipeline_failure++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //commit
|
|
|
+ commit.setCommit_times(commit_times);
|
|
|
+ commit.setValid_commit_times(valid_commit_time);
|
|
|
+ commit.setBuglist_commit(buglist_commit);
|
|
|
+ commit.setFeature_commit(feature_commit);
|
|
|
+ commit.setCommit_msg_overview(commit_msg_overview);
|
|
|
+ //test
|
|
|
+ test.setTest_times(test_times);
|
|
|
+ test.setTest_concurrency_count(test_concurrency_count);
|
|
|
+ test.setTest_concurrency_success(test_success);
|
|
|
+ test.setTest_concurrency_failure(test_failure);
|
|
|
+ //pipeline
|
|
|
+ pipeline.setPipeline_deploy(pipeline_deploy);
|
|
|
+ pipeline.setPipeline_pass(pipeline_pass);
|
|
|
+ pipeline.setPipline_failure(pipeline_failure);
|
|
|
+
|
|
|
+ formatStudent.setCommit(commit);
|
|
|
+ formatStudent.setTest(test);
|
|
|
+ formatStudent.setPipeline(pipeline);
|
|
|
+
|
|
|
+ return formatStudent;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public FormatGroup getGroupAnalysis(Integer project_id){
|
|
|
- return null;
|
|
|
+ //暂时不存在GroupId,先使用ProjectId代替
|
|
|
+ FormatGroup formatGroup = new FormatGroup();
|
|
|
+ Integer projectAId = project_id;
|
|
|
+ Integer projectBId = projectRelateDao.findById(project_id).get().getRelateId();
|
|
|
+
|
|
|
+ List<Integer> projectList = new ArrayList<>();
|
|
|
+ projectList.add(projectAId);
|
|
|
+ projectList.add(projectBId);
|
|
|
+ List<Project> projects = new ArrayList<>();
|
|
|
+ projects.add(projectDao.findById(projectAId).get());
|
|
|
+ projects.add(projectDao.findById(projectBId).get());
|
|
|
+
|
|
|
+ List<Integer> userIds = devcloudProjectDao.findById(project_id).get().getUserIds();
|
|
|
+
|
|
|
+ List<User> users = new ArrayList<>();
|
|
|
+ for(int i=0;i<userIds.size();i++){
|
|
|
+ Integer userId = userIds.get(i);
|
|
|
+ users.add(userDao.findByUserId(userId));
|
|
|
+ }
|
|
|
+ int n = userIds.size();
|
|
|
+
|
|
|
+ formatGroup.setProjects(projects);
|
|
|
+ formatGroup.setStudents(users);
|
|
|
+
|
|
|
+ //放入小组Commit信息,测试信息,流水线信息
|
|
|
+ Commit commit = new Commit();
|
|
|
+ Test test = new Test();
|
|
|
+ Pipeline pipeline = new Pipeline();
|
|
|
+
|
|
|
+ Integer commit_times=0,valid_commit_time=0,buglist_commit=0,feature_commit=0;
|
|
|
+ //记录小组不同成员的commit贡献
|
|
|
+// Integer commitTimesA=0,commitTimesB=0,commitTimesC=0,commitTimesD=0;
|
|
|
+ Integer[] commitTimes = new Integer[n];
|
|
|
+ List<String> commit_msg_overview = new ArrayList<>();
|
|
|
+ Integer test_success=0,test_failure=0,test_times=0,test_concurrency_count=0;
|
|
|
+ //记录小组不同成员的test贡献
|
|
|
+// Integer testTimesA=0,testTimesB=0,testTimesC=0,testTimesD=0;
|
|
|
+ Integer[] testTimes = new Integer[n];
|
|
|
+ Integer pipeline_deploy=0,pipeline_pass=0,pipeline_failure=0;
|
|
|
+ //记录小组不同成员的deploy贡献
|
|
|
+// Integer pipeTimesA=0,pipeTimesB=0,pipeTimesC=0,pipeTimesD=0;
|
|
|
+ Integer[] pipeTimes = new Integer[n];
|
|
|
+
|
|
|
+ //
|
|
|
+ for(int i=0;i<projects.size();i++){
|
|
|
+ Integer projectId = projectList.get(i);
|
|
|
+ DevcloudInfo devcloudInfo = devcloudInfoDao.findById(projectId).get();
|
|
|
+
|
|
|
+ //遍历devInfo中的commit信息
|
|
|
+ List<CommitInfo> commitInfos = devcloudInfo.getCommitList();
|
|
|
+ commit_times = commitInfos.size();
|
|
|
+ for(CommitInfo commitInfo : commitInfos){
|
|
|
+ for(int j=0;j<userIds.size();j++){
|
|
|
+ Integer user_id = userIds.get(j);
|
|
|
+ if(commitInfo.getUserId().equals(user_id)){
|
|
|
+ commitTimes[j]++;
|
|
|
+ commit_msg_overview.add(commitInfo.getMessage());
|
|
|
+ //如果是需求的commit
|
|
|
+ if(commitInfo.getType().toLowerCase().equals("tree_id")){
|
|
|
+ feature_commit++;
|
|
|
+ }
|
|
|
+ //如果是bug_list的commit
|
|
|
+ if(commitInfo.getType().toLowerCase().equals("bug_id")){
|
|
|
+ buglist_commit++;
|
|
|
+ }
|
|
|
+ //判断是否是有效的commit
|
|
|
+ if(commitInfo.getMessage().startsWith("feat:")||commitInfo.getMessage().startsWith("fix:")){
|
|
|
+ valid_commit_time++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //遍历devInfo中的test信息
|
|
|
+ List<TestInfo> testInfos = devcloudInfo.getTestList();
|
|
|
+ test_times = testInfos.size();
|
|
|
+ for(TestInfo testInfo : testInfos){
|
|
|
+ for(int j=0;j<userIds.size();j++){
|
|
|
+ Integer user_id = userIds.get(j);
|
|
|
+ if(testInfo.getUserId().equals(user_id)){
|
|
|
+ testTimes[j]++;
|
|
|
+ test_success += testInfo.getSuccess();
|
|
|
+ test_failure += testInfo.getFailure();
|
|
|
+ test_concurrency_count += testInfo.getSuccess();
|
|
|
+ test_concurrency_count += testInfo.getFailure();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //遍历devInfo中的pipeline信息
|
|
|
+ List<PipelineInfo> pipelineInfos = devcloudInfo.getPipelineList();
|
|
|
+ for(PipelineInfo pipelineInfo : pipelineInfos){
|
|
|
+ //遍历每个流水线中的部署记录
|
|
|
+ List<RecordInfo> recordInfos = pipelineInfo.getRecordList();
|
|
|
+ for(int j=0;j<userIds.size();j++){
|
|
|
+ Integer user_id = userIds.get(j);
|
|
|
+ for(RecordInfo recordInfo : recordInfos){
|
|
|
+ if(recordInfo.getUserId().equals(user_id)){
|
|
|
+ pipeline_deploy++;
|
|
|
+ pipeTimes[j]++;
|
|
|
+ if(recordInfo.getResult().equals("部署成功")){
|
|
|
+ pipeline_pass++;
|
|
|
+ }
|
|
|
+ if(recordInfo.getResult().equals("部署失败")){
|
|
|
+ pipeline_failure++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+ //commit
|
|
|
+ commit.setCommit_times(commit_times);
|
|
|
+ commit.setValid_commit_times(valid_commit_time);
|
|
|
+ commit.setBuglist_commit(buglist_commit);
|
|
|
+ commit.setFeature_commit(feature_commit);
|
|
|
+ commit.setCommit_msg_overview(commit_msg_overview);
|
|
|
+ List<Contribution> commitContribution = new ArrayList<>();
|
|
|
+ for(int i=0;i<userIds.size();i++){
|
|
|
+ Contribution contribution = new Contribution();
|
|
|
+ contribution.setName(users.get(i).getUsername());
|
|
|
+ contribution.setTimes(commitTimes[i]);
|
|
|
+ contribution.setProportion(Double.valueOf(df.format(commitTimes[i]/commit_times)));
|
|
|
+ commitContribution.add(contribution);
|
|
|
+ }
|
|
|
+ commit.setCommit_contribution(commitContribution);
|
|
|
+ //test
|
|
|
+ test.setTest_times(test_times);
|
|
|
+ test.setTest_concurrency_count(test_concurrency_count);
|
|
|
+ test.setTest_concurrency_success(test_success);
|
|
|
+ test.setTest_concurrency_failure(test_failure);
|
|
|
+ List<Contribution> testContribution = new ArrayList<>();
|
|
|
+ for(int i=0;i<userIds.size();i++){
|
|
|
+ Contribution contribution = new Contribution();
|
|
|
+ contribution.setName(users.get(i).getUsername());
|
|
|
+ contribution.setTimes(testTimes[i]);
|
|
|
+ contribution.setProportion(Double.valueOf(df.format(testTimes[i]/test_times)));
|
|
|
+ testContribution.add(contribution);
|
|
|
+ }
|
|
|
+ test.setTest_contribution(testContribution);
|
|
|
+ //pipeline
|
|
|
+ pipeline.setPipeline_deploy(pipeline_deploy);
|
|
|
+ pipeline.setPipeline_pass(pipeline_pass);
|
|
|
+ pipeline.setPipline_failure(pipeline_failure);
|
|
|
+ List<Contribution> deployContribution = new ArrayList<>();
|
|
|
+ for(int i=0;i<userIds.size();i++){
|
|
|
+ Contribution contribution = new Contribution();
|
|
|
+ contribution.setName(users.get(i).getUsername());
|
|
|
+ contribution.setTimes(pipeTimes[i]);
|
|
|
+ contribution.setProportion(Double.valueOf(df.format(pipeTimes[i]/pipeline_deploy)));
|
|
|
+ deployContribution.add(contribution);
|
|
|
+ }
|
|
|
+ pipeline.setPipeline_contribution(deployContribution);
|
|
|
+
|
|
|
+ formatGroup.setCommit(commit);
|
|
|
+ formatGroup.setTest(test);
|
|
|
+ formatGroup.setPipeline(pipeline);
|
|
|
+
|
|
|
+ return formatGroup;
|
|
|
}
|
|
|
|
|
|
}
|