use of org.sonar.server.metric.UnanalyzedLanguageMetrics.UNANALYZED_CPP_KEY in project sonarqube by SonarSource.
the class TelemetryDataLoaderImpl method load.
@Override
public TelemetryData load() {
TelemetryData.Builder data = TelemetryData.builder();
data.setServerId(server.getId());
data.setVersion(server.getVersion());
data.setEdition(editionProvider.get().orElse(null));
ofNullable(licenseReader).flatMap(reader -> licenseReader.read()).ifPresent(license -> data.setLicenseType(license.getType()));
Function<PluginInfo, String> getVersion = plugin -> plugin.getVersion() == null ? "undefined" : plugin.getVersion().getName();
Map<String, String> plugins = pluginRepository.getPluginInfos().stream().collect(MoreCollectors.uniqueIndex(PluginInfo::getKey, getVersion));
data.setPlugins(plugins);
long userCount = userIndex.search(UserQuery.builder().build(), new SearchOptions().setLimit(1)).getTotal();
data.setUserCount(userCount);
ProjectMeasuresStatistics projectMeasuresStatistics = projectMeasuresIndex.searchTelemetryStatistics();
data.setProjectMeasuresStatistics(projectMeasuresStatistics);
try (DbSession dbSession = dbClient.openSession(false)) {
data.setDatabase(loadDatabaseMetadata(dbSession));
data.setUsingBranches(dbClient.branchDao().hasNonMainBranches(dbSession));
SumNclocDbQuery query = SumNclocDbQuery.builder().setOnlyPrivateProjects(false).build();
data.setNcloc(dbClient.liveMeasureDao().sumNclocOfBiggestBranch(dbSession, query));
long numberOfUnanalyzedCMeasures = dbClient.liveMeasureDao().countProjectsHavingMeasure(dbSession, UNANALYZED_C_KEY);
long numberOfUnanalyzedCppMeasures = dbClient.liveMeasureDao().countProjectsHavingMeasure(dbSession, UNANALYZED_CPP_KEY);
editionProvider.get().filter(edition -> edition.equals(COMMUNITY)).ifPresent(edition -> {
data.setHasUnanalyzedC(numberOfUnanalyzedCMeasures > 0);
data.setHasUnanalyzedCpp(numberOfUnanalyzedCppMeasures > 0);
});
data.setAlmIntegrationCountByAlm(countAlmUsage(dbSession));
data.setExternalAuthenticationProviders(dbClient.userDao().selectExternalIdentityProviders(dbSession));
data.setSonarlintWeeklyUsers(dbClient.userDao().countSonarlintWeeklyUsers(dbSession));
addScmInformationToTelemetry(dbSession, data);
addCiInformationToTelemetry(dbSession, data);
}
setSecurityCustomConfigIfPresent(data);
Optional<String> installationDateProperty = internalProperties.read(InternalProperties.INSTALLATION_DATE);
installationDateProperty.ifPresent(s -> data.setInstallationDate(Long.valueOf(s)));
Optional<String> installationVersionProperty = internalProperties.read(InternalProperties.INSTALLATION_VERSION);
data.setInstallationVersion(installationVersionProperty.orElse(null));
data.setInDocker(dockerSupport.isRunningInDocker());
return data.build();
}
Aggregations