|
|
@@ -1447,4 +1447,174 @@ public class DevcloudDataAnalysisServiceImpl implements DevcloudDataAnalysisServ
|
|
|
return formatGroup;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public FormatStudent getProjectAnalysisByUserId(Integer project_id,Integer user_id){
|
|
|
+ FormatStudent formatStudent = new FormatStudent();
|
|
|
+ User user = userDao.findByUserId(user_id);
|
|
|
+ DevcloudUser devcloudUser;
|
|
|
+
|
|
|
+ Optional<DevcloudUser> result = devcloudUserDao.findById(user_id);
|
|
|
+ //如果devcloudUser不存在,说明用户还没有加入任何项目
|
|
|
+ //但如果存在对应的User信息,则帮用户新建devcloudUser
|
|
|
+ if(!result.isPresent()){
|
|
|
+// System.out.println("没有查找到学生id");
|
|
|
+ }else {
|
|
|
+ devcloudUser = devcloudUserDao.findById(user_id).get();
|
|
|
+ }
|
|
|
+
|
|
|
+ //放入展示数据
|
|
|
+ formatStudent.setUserId(user_id);
|
|
|
+ formatStudent.setName(user.getName());
|
|
|
+ formatStudent.setEmail(user.getEmail());
|
|
|
+
|
|
|
+ //根据用户id找到和该用户关联的所有项目id
|
|
|
+// List<Integer> projectList = devcloudUserDao.findById(user_id).get().getProjectIds();
|
|
|
+ List<Integer> projectList = new ArrayList<>();
|
|
|
+ projectList.add(project_id);
|
|
|
+
|
|
|
+ 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();
|
|
|
+ //新增
|
|
|
+ Bug bugList = new Bug();
|
|
|
+ TreeNode treeNode = new TreeNode();
|
|
|
+
|
|
|
+ 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;
|
|
|
+ //新增bugList和TreeNode
|
|
|
+ Integer bug_times=0,high_times=0,finished_times=0;
|
|
|
+ Integer treeNode_times=0,high_treeNode_times=0,finished_treeNode_times=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() == null) {
|
|
|
+ continue;
|
|
|
+ }else 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() == null) {
|
|
|
+ continue;
|
|
|
+ }else 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() == null) {
|
|
|
+ continue;
|
|
|
+ }else if(recordInfo.getUserId().equals(user_id)){
|
|
|
+ pipeline_deploy++;
|
|
|
+ if(recordInfo.getResult().equals("部署成功")){
|
|
|
+ pipeline_pass++;
|
|
|
+ }
|
|
|
+ if(recordInfo.getResult().equals("部署失败")){
|
|
|
+ pipeline_failure++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //遍历devInfo中的bugList信息
|
|
|
+ List<BugInfo> bugInfos = devcloudInfo.getBugList();
|
|
|
+ for(BugInfo bugInfo : bugInfos){
|
|
|
+ if(bugInfo.getUserId() == null){
|
|
|
+ continue;
|
|
|
+ }else if(bugInfo.getUserId().equals(user_id)){
|
|
|
+ bug_times++;
|
|
|
+ if(bugInfo.getPriority().toLowerCase().equals("high")){
|
|
|
+ high_times++;
|
|
|
+ }
|
|
|
+ if(bugInfo.getBugState().toLowerCase().equals("finished")){
|
|
|
+ finished_times++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //遍历devInfo的treeNode信息
|
|
|
+ List<TreeNodeInfo> treeNodeInfos = devcloudInfo.getTreeNodeList();
|
|
|
+ for(TreeNodeInfo treeNodeInfo : treeNodeInfos){
|
|
|
+ if(treeNodeInfo.getUserId() == null){
|
|
|
+ continue;
|
|
|
+ }else if(treeNodeInfo.getUserId().equals(user_id)){
|
|
|
+ treeNode_times++;
|
|
|
+ if(treeNodeInfo.getPriority().toLowerCase().equals("high")){
|
|
|
+ high_treeNode_times++;
|
|
|
+ }
|
|
|
+ if(treeNodeInfo.getState().toLowerCase().equals("finished")){
|
|
|
+ finished_treeNode_times++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //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);
|
|
|
+ //bugList
|
|
|
+ bugList.setBug_times(bug_times);
|
|
|
+ bugList.setHigh_times(high_times);
|
|
|
+ bugList.setFinished_times(finished_times);
|
|
|
+ //treeNode
|
|
|
+ treeNode.setTreeNode_times(treeNode_times);
|
|
|
+ treeNode.setHigh_treeNode_times(high_treeNode_times);
|
|
|
+ treeNode.setFinished_treeNode_times(finished_treeNode_times);
|
|
|
+
|
|
|
+ formatStudent.setCommit(commit);
|
|
|
+ formatStudent.setTest(test);
|
|
|
+ formatStudent.setPipeline(pipeline);
|
|
|
+ formatStudent.setBuglist(bugList);
|
|
|
+ formatStudent.setTreeNode(treeNode);
|
|
|
+
|
|
|
+ return formatStudent;
|
|
|
+ }
|
|
|
+
|
|
|
}
|