|
|
@@ -1133,4 +1133,318 @@ public class DevcloudDataAnalysisServiceImpl implements DevcloudDataAnalysisServ
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public FormatGroup getProjectAnalysis(Integer project_id){
|
|
|
+ //暂时不存在GroupId,先使用ProjectId代替
|
|
|
+ FormatGroup formatGroup = new FormatGroup();
|
|
|
+ //记录该小组拥有的所有项目的id
|
|
|
+ List<Integer> projectList = new ArrayList<>();
|
|
|
+ //记录所有项目的信息,用于小组项目信息展示
|
|
|
+ List<Project> projects = new ArrayList<>();
|
|
|
+
|
|
|
+ //先将传入的project加入List
|
|
|
+ projectList.add(project_id);
|
|
|
+ projects.add(projectDao.findById(project_id).get());
|
|
|
+
|
|
|
+ Optional<DevcloudProject> result2 = devcloudProjectDao.findById(project_id);
|
|
|
+ if(!result2.isPresent()){
|
|
|
+ System.out.println("没有找到项目的成员信息");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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();
|
|
|
+ //新增
|
|
|
+ Bug bugList = new Bug();
|
|
|
+ TreeNode treeNode = new TreeNode();
|
|
|
+
|
|
|
+ Integer commit_times=0,valid_commit_time=0,buglist_commit=0,feature_commit=0;
|
|
|
+ //记录小组不同成员的commit贡献
|
|
|
+ int[] commitTimes = new int[n];
|
|
|
+ List<String> commit_msg_overview = new ArrayList<>();
|
|
|
+ Integer test_success=0,test_failure=0,test_times=0,test_concurrency_count=0;
|
|
|
+ //记录小组不同成员的test贡献
|
|
|
+ int[] testTimes = new int[n];
|
|
|
+ Integer pipeline_deploy=0,pipeline_pass=0,pipeline_failure=0;
|
|
|
+ //记录小组不同成员的deploy贡献
|
|
|
+ int[] pipeTimes = new int[n];
|
|
|
+ //新增bugList,treeNode
|
|
|
+ Integer bug_times=0,high_times=0,finished_times=0;
|
|
|
+ //记录小组不同成员的bugList贡献
|
|
|
+ int[] bugTimes = new int[n];
|
|
|
+ Integer treeNode_times=0,high_treeNode_times=0,finished_treeNode_times=0;
|
|
|
+ //记录小组不同成员的treeNode贡献
|
|
|
+ int[] treeNodeTimes = new int[n];
|
|
|
+
|
|
|
+ //遍历所有的项目,将整体信息作为小组的分析情况
|
|
|
+ for(int i=0;i<projectList.size();i++){
|
|
|
+ Integer projectId = projectList.get(i);
|
|
|
+ DevcloudInfo devcloudInfo;
|
|
|
+ Optional<DevcloudInfo> result3 = devcloudInfoDao.findById(projectId);
|
|
|
+ //如果找不到对应的项目信息则跳过该项目
|
|
|
+ if(!result3.isPresent()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ devcloudInfo = devcloudInfoDao.findById(projectId).get();
|
|
|
+
|
|
|
+ //遍历devInfo中的commit信息
|
|
|
+ List<CommitInfo> commitInfos = devcloudInfo.getCommitList();
|
|
|
+// System.out.println("commitInfosSize: "+commitInfos.size());
|
|
|
+// commit_times += commitInfos.size();
|
|
|
+ for(CommitInfo commitInfo : commitInfos){
|
|
|
+ if(commitInfo.getUserId() == null || isInGroup(commitInfo.getUserId(),userIds)==false){
|
|
|
+ continue;
|
|
|
+ }else{
|
|
|
+ commit_times++;
|
|
|
+ commit_msg_overview.add(commitInfo.getMessage());
|
|
|
+ //如果是需求的commit
|
|
|
+ if(commitInfo.getType().toLowerCase().equals("tree_id")||commitInfo.getMessage().startsWith("feat:")){
|
|
|
+ feature_commit++;
|
|
|
+ }
|
|
|
+ //如果是bug_list的commit
|
|
|
+ if(commitInfo.getType().toLowerCase().equals("bug_id")||commitInfo.getMessage().startsWith("fix:")){
|
|
|
+ buglist_commit++;
|
|
|
+ }
|
|
|
+ //判断是否是有效的commit
|
|
|
+ if(commitInfo.getMessage().startsWith("feat:")||commitInfo.getMessage().startsWith("fix:")){
|
|
|
+ valid_commit_time++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(int j=0;j<userIds.size();j++){
|
|
|
+ Integer user_id = userIds.get(j);
|
|
|
+ if(commitInfo.getUserId() == null) {
|
|
|
+ continue;
|
|
|
+ }else if(commitInfo.getUserId().equals(user_id)){
|
|
|
+ commitTimes[j]++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //遍历devInfo中的test信息
|
|
|
+ List<TestInfo> testInfos = devcloudInfo.getTestList();
|
|
|
+// test_times += testInfos.size();
|
|
|
+ for(TestInfo testInfo : testInfos){
|
|
|
+ if(testInfo.getUserId() == null || isInGroup(testInfo.getUserId(),userIds)==false){
|
|
|
+ continue;
|
|
|
+ }else {
|
|
|
+ test_times++;
|
|
|
+ test_success += testInfo.getSuccess();
|
|
|
+ test_failure += testInfo.getFailure();
|
|
|
+ test_concurrency_count += testInfo.getSuccess();
|
|
|
+ test_concurrency_count += testInfo.getFailure();
|
|
|
+ }
|
|
|
+ for(int j=0;j<userIds.size();j++){
|
|
|
+ Integer user_id = userIds.get(j);
|
|
|
+ if(testInfo.getUserId() == null) {
|
|
|
+ continue;
|
|
|
+ }else if(testInfo.getUserId().equals(user_id)){
|
|
|
+ testTimes[j]++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //遍历devInfo中的pipeline信息
|
|
|
+ List<PipelineInfo> pipelineInfos = devcloudInfo.getPipelineList();
|
|
|
+ for(PipelineInfo pipelineInfo : pipelineInfos){
|
|
|
+ //遍历每个流水线中的部署记录
|
|
|
+ List<RecordInfo> recordInfos = pipelineInfo.getRecordList();
|
|
|
+ for(RecordInfo recordInfo : recordInfos){
|
|
|
+ if(recordInfo.getUserId() == null || isInGroup(recordInfo.getUserId(),userIds)==false){
|
|
|
+ continue;
|
|
|
+ }else {
|
|
|
+ pipeline_deploy++;
|
|
|
+ if(recordInfo.getResult().equals("部署成功")){
|
|
|
+ pipeline_pass++;
|
|
|
+ }
|
|
|
+ if(recordInfo.getResult().equals("部署失败")){
|
|
|
+ pipeline_failure++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(int j=0;j<userIds.size();j++){
|
|
|
+ Integer user_id = userIds.get(j);
|
|
|
+ if(recordInfo.getUserId() == null) {
|
|
|
+ continue;
|
|
|
+ }else if(recordInfo.getUserId().equals(user_id)){
|
|
|
+ pipeTimes[j]++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //遍历devInfo中的bugList信息
|
|
|
+ List<BugInfo> bugInfos = devcloudInfo.getBugList();
|
|
|
+ for(BugInfo bugInfo : bugInfos){
|
|
|
+ if(bugInfo.getUserId() == null || isInGroup(bugInfo.getUserId(),userIds)==false){
|
|
|
+ continue;
|
|
|
+ }else {
|
|
|
+ bug_times++;
|
|
|
+ if(bugInfo.getPriority().toLowerCase().equals("high")){
|
|
|
+ high_times++;
|
|
|
+ }
|
|
|
+ if(bugInfo.getBugState().toLowerCase().equals("finished")){
|
|
|
+ finished_times++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(int j=0;j<userIds.size();j++){
|
|
|
+ Integer user_id = userIds.get(j);
|
|
|
+ if(bugInfo.getUserId() == null){
|
|
|
+ continue;
|
|
|
+ }else if(bugInfo.getUserId().equals(user_id)){
|
|
|
+ bugTimes[j]++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //遍历devInfo的treeNode信息
|
|
|
+ List<TreeNodeInfo> treeNodeInfos = devcloudInfo.getTreeNodeList();
|
|
|
+ for(TreeNodeInfo treeNodeInfo : treeNodeInfos){
|
|
|
+ if(treeNodeInfo.getUserId() == null || isInGroup(treeNodeInfo.getUserId(),userIds)==false){
|
|
|
+ continue;
|
|
|
+ }else {
|
|
|
+ treeNode_times++;
|
|
|
+ if(treeNodeInfo.getPriority().toLowerCase().equals("high")){
|
|
|
+ high_treeNode_times++;
|
|
|
+ }
|
|
|
+ if(treeNodeInfo.getState().toLowerCase().equals("finished")){
|
|
|
+ finished_treeNode_times++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(int j=0;j<userIds.size();j++){
|
|
|
+ Integer user_id = userIds.get(j);
|
|
|
+ if(treeNodeInfo.getUserId() == null){
|
|
|
+ continue;
|
|
|
+ }else if(treeNodeInfo.getUserId().equals(user_id)){
|
|
|
+ treeNodeTimes[j]++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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.setUserId(users.get(i).getUserId());
|
|
|
+ contribution.setName(users.get(i).getName());
|
|
|
+ contribution.setTimes(commitTimes[i]);
|
|
|
+ Double value;
|
|
|
+ if(commit_times == 0){
|
|
|
+ value = 0.0;
|
|
|
+ }else {
|
|
|
+ value = (double)commitTimes[i]/(double)commit_times;
|
|
|
+ }
|
|
|
+ contribution.setProportion(Double.valueOf(df.format(value)));
|
|
|
+ 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.setUserId(users.get(i).getUserId());
|
|
|
+ contribution.setName(users.get(i).getName());
|
|
|
+ contribution.setTimes(testTimes[i]);
|
|
|
+ Double value;
|
|
|
+ if(test_times == 0){
|
|
|
+ value = 0.0;
|
|
|
+ }else {
|
|
|
+ value = (double)testTimes[i]/(double)test_times;
|
|
|
+ }
|
|
|
+ contribution.setProportion(Double.valueOf(df.format(value)));
|
|
|
+ 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.setUserId(users.get(i).getUserId());
|
|
|
+ contribution.setName(users.get(i).getName());
|
|
|
+ contribution.setTimes(pipeTimes[i]);
|
|
|
+ Double value;
|
|
|
+ if(pipeline_deploy == 0){
|
|
|
+ value = 0.0;
|
|
|
+ }else {
|
|
|
+ value = (double)pipeTimes[i]/(double)pipeline_deploy;
|
|
|
+ }
|
|
|
+ contribution.setProportion(Double.valueOf(df.format(value)));
|
|
|
+ deployContribution.add(contribution);
|
|
|
+ }
|
|
|
+ pipeline.setPipeline_contribution(deployContribution);
|
|
|
+ //bugList
|
|
|
+ bugList.setBug_times(bug_times);
|
|
|
+ bugList.setHigh_times(high_times);
|
|
|
+ bugList.setFinished_times(finished_times);
|
|
|
+ List<Contribution> bugContribution = new ArrayList<>();
|
|
|
+ for(int i=0;i<userIds.size();i++){
|
|
|
+ Contribution contribution = new Contribution();
|
|
|
+ contribution.setUserId(users.get(i).getUserId());
|
|
|
+ contribution.setName(users.get(i).getName());
|
|
|
+ contribution.setTimes(bugTimes[i]);
|
|
|
+ Double value;
|
|
|
+ if(bug_times == 0){
|
|
|
+ value = 0.0;
|
|
|
+ }else {
|
|
|
+ value = (double)bugTimes[i]/(double)bug_times;
|
|
|
+ }
|
|
|
+ contribution.setProportion(Double.valueOf(df.format(value)));
|
|
|
+ bugContribution.add(contribution);
|
|
|
+ }
|
|
|
+ bugList.setBug_contribution(bugContribution);
|
|
|
+ //treeNode
|
|
|
+ treeNode.setTreeNode_times(treeNode_times);
|
|
|
+ treeNode.setHigh_treeNode_times(high_treeNode_times);
|
|
|
+ treeNode.setFinished_treeNode_times(finished_treeNode_times);
|
|
|
+ List<Contribution> treeNodeContribution = new ArrayList<>();
|
|
|
+ for(int i=0;i<userIds.size();i++){
|
|
|
+ Contribution contribution = new Contribution();
|
|
|
+ contribution.setUserId(users.get(i).getUserId());
|
|
|
+ contribution.setName(users.get(i).getName());
|
|
|
+ contribution.setTimes(treeNodeTimes[i]);
|
|
|
+ Double value;
|
|
|
+ if(bug_times == 0){
|
|
|
+ value = 0.0;
|
|
|
+ }else {
|
|
|
+ value = (double)treeNodeTimes[i]/(double)treeNode_times;
|
|
|
+ }
|
|
|
+ contribution.setProportion(Double.valueOf(df.format(value)));
|
|
|
+ treeNodeContribution.add(contribution);
|
|
|
+ }
|
|
|
+ treeNode.setTreeNode_contribution(treeNodeContribution);
|
|
|
+
|
|
|
+ formatGroup.setCommit(commit);
|
|
|
+ formatGroup.setTest(test);
|
|
|
+ formatGroup.setPipeline(pipeline);
|
|
|
+ formatGroup.setBuglist(bugList);
|
|
|
+ formatGroup.setTreeNode(treeNode);
|
|
|
+
|
|
|
+ return formatGroup;
|
|
|
+ }
|
|
|
+
|
|
|
}
|