in usage-statistics-impl/src/jetbrains/buildServer/usageStatistics/impl/providers/VersionedSettingsBuildsUsagesStatisticsProvider.java [66:99]
protected void accept(@NotNull final UsageStatisticsPublisher publisher,
@NotNull final UsageStatisticsPresentationManager presentationManager,
@NotNull final String periodDescription,
final long startDate) {
Map<String, Integer> buildTypeBuildsCount = mySql.runAndRetry(new DBAction<Map<String, Integer>>() {
public Map<String, Integer> run(final DBFunctions dbf) throws DBException {
return BUILDS_WITH_SETTINGS.execute(dbf, startDate);
}
});
Map<String, Integer> vcs2buildCount = new HashMap<String, Integer>();
Map<SProject, AtomicReference<SVcsRoot>> projectSettingsRootCache = new HashMap<SProject, AtomicReference<SVcsRoot>>();
int total = 0;
for (Map.Entry<String, Integer> e : buildTypeBuildsCount.entrySet()) {
SBuildType bt = myProjectManager.findBuildTypeById(e.getKey());
if (bt == null)
continue;
SVcsRoot root = getSettingsRoot(projectSettingsRootCache, bt.getProject());
if (root == null)
continue;
int count = e.getValue();
aggregateBuildCount(vcs2buildCount, root.getVcsDisplayName(), count);
total += count;
}
final UsageStatisticsFormatter formatter = new PercentageFormatter(total);
for (Map.Entry<String, Integer> e : vcs2buildCount.entrySet()) {
String statId = makeId(e.getKey(), periodDescription);
presentationManager.applyPresentation(statId, e.getKey(), myGroupName, formatter, "Builds count (% of builds with settings from VCS during the period)");
publisher.publishStatistic(statId, e.getValue());
}
}