private List<Double> getBugFixTimes(String projectId, Date from, Date to) { List<Double> result = new ArrayList<>(); Collection<VcsCommitInfo> commits = myVcsProvider.getHistoryChunk(projectId, from, to); Date start = commits.iterator().next().getDate(); for (VcsCommitInfo commitInfo : commits) { if (VcsCommitInfoUtils.isRelatedToBugIssue(commitInfo)) { result.add(1.0 * (commitInfo.getDate().getTime() - start.getTime()) / (86400 * 1000)); } } return result; }
public void process(String projectId, Date from, Date to) { reset(); Collection<VcsCommitInfo> allCommits = getCommitsForProject(projectId, from, to); generateTestAndTrainSets(allCommits); System.out.println("Processing commits..."); int total = allCommits.size(); int counter = 0; long startTime = System.currentTimeMillis(); for (VcsCommitInfo commitInfo : allCommits) { counter++; if (counter % 100 == 0) { System.out.println( counter + " / " + total + " | last 100 processed in " + (System.currentTimeMillis() - startTime) + " ms"); startTime = System.currentTimeMillis(); } for (String filename : commitInfo.getAffectedFiles()) { if (!commitAffections.containsKey(filename)) { commitAffections.put(filename, new ArrayList<VcsCommitInfo>()); } commitAffections.get(filename).add(commitInfo); } if (VcsCommitInfoUtils.isRelatedToBugIssue(commitInfo)) { for (String filename : commitInfo.getAffectedFiles()) { if (!bugFixCommitAffections.containsKey(filename)) { bugFixCommitAffections.put(filename, new ArrayList<VcsCommitInfo>()); } bugFixCommitAffections.get(filename).add(commitInfo); } } for (PredictionModel model : myModels) { if (trainSet.contains(commitInfo.getCommitId())) { // train the model model.update(commitInfo, true); } if (testSet.contains(commitInfo.getCommitId())) { // update the model without training and get prediction data Map<String, List<VcsCommitInfo>> topAppearanceMapForCurrentModel = appearancesInTop.get(model); for (String fileInTop : model.getPredictionData().keySet()) { if (!topAppearanceMapForCurrentModel.containsKey(fileInTop)) { topAppearanceMapForCurrentModel.put(fileInTop, new ArrayList<VcsCommitInfo>()); } topAppearanceMapForCurrentModel.get(fileInTop).add(commitInfo); } } } } }