protected void saveLeadersToDatabase(List<Leader> Leaders, Repository repository) throws JSONException { String json = convertLeadersToJson(Leaders).toString(); String repoSlug = repository.getSlug(); String projectKey = repository.getProject().getKey(); pluginSettings.put(projectKey + "." + repoSlug + ".prInfo", json); }
public long getPullRequestCount(Repository repository) { return pullRequestService.count( new PullRequestSearchRequest.Builder() .fromRepositoryId(repository.getId()) .state(PullRequestState.DECLINED) .build()) + pullRequestService.count( new PullRequestSearchRequest.Builder() .fromRepositoryId(repository.getId()) .state(PullRequestState.MERGED) .build()) + pullRequestService.count( new PullRequestSearchRequest.Builder() .fromRepositoryId(repository.getId()) .state(PullRequestState.OPEN) .build()); }
public PageRequest getAllPullRequests( Scoring scoring, List<Leader> Leaders, Repository repository, PageRequest pageRequest) { Page<PullRequest> prPage = pullRequestService.search( new PullRequestSearchRequest.Builder().toRepositoryId(repository.getId()).build(), pageRequest); Iterator<PullRequest> prPageI = prPage.getValues().iterator(); while (prPageI.hasNext()) { PullRequest pr = prPageI.next(); addToLeaders(scoring, Leaders, pr); } return prPage.getNextPageRequest(); }
public Map<String, Object> getLeadersFromDatabase( Scoring scoring, Repository repository, String history) throws JSONException { // Get string from database for repo String repoLeaderboardString = ""; Object repoLeaderboard = pluginSettings.get( repository.getProject().getKey() + "." + repository.getSlug() + ".prInfo"); if (repoLeaderboard != null) { repoLeaderboardString = repoLeaderboard.toString(); } // convert json to leaders List<Leader> leaders = convertJsonToLeaders(scoring, repoLeaderboardString); if (history != null) { for (Leader leader : leaders) { leader.setScore(history); } sortLeaders(leaders); } Map<String, Object> map = new HashMap<String, Object>(); map.put("leaders", leaders); return map; }