@Test public void existsNonMainBranch() { assertThat(underTest.hasNonMainBranches(dbSession)).isFalse(); ComponentDto project = db.components().insertPrivateProject(); assertThat(underTest.hasNonMainBranches(dbSession)).isFalse(); ComponentDto branch1 = db.components().insertProjectBranch(project); assertThat(underTest.hasNonMainBranches(dbSession)).isTrue(); ComponentDto branch2 = db.components().insertProjectBranch(project); assertThat(underTest.hasNonMainBranches(dbSession)).isTrue(); }
public TelemetryData load() { TelemetryData.Builder data = TelemetryData.builder(); data.setServerId(server.getId()); data.setVersion(server.getVersion()); data.setEdition(editionProvider.get()); 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) .setOrganizationUuid(defaultOrganizationProvider.get().getUuid()) .build(); data.setNcloc(dbClient.liveMeasureDao().sumNclocOfBiggestLongLivingBranch(dbSession, query)); } return data.build(); }
public TelemetryData load() { TelemetryData.Builder data = TelemetryData.builder(); data.setServerId(server.getId()); data.setVersion(server.getVersion()); data.setEdition(editionProvider.get()); 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)); data.setNcloc(dbClient.liveMeasureDao().sumNclocOfBiggestLongLivingBranch(dbSession)); } return data.build(); }