From cf55c2180b2217738e29a3ebe7236a9c5b572379 Mon Sep 17 00:00:00 2001 From: Alain Kermis Date: Wed, 25 Jan 2023 15:20:50 +0100 Subject: [PATCH] SONAR-18219 Add telemetry fields for CaYC --- .../org/sonar/db/measure/LiveMeasureDao.java | 10 +- .../sonar/db/measure/LiveMeasureMapper.java | 3 + .../sonar/db/measure/LiveMeasureMapper.xml | 10 ++ .../sonar/db/measure/LiveMeasureDaoTest.java | 27 +++ .../sonar/server/telemetry/TelemetryData.java | 158 +++++++++++++++++- .../telemetry/TelemetryDataJsonWriter.java | 19 ++- .../TelemetryDataJsonWriterTest.java | 68 ++++++-- .../telemetry/TelemetryDataLoaderImpl.java | 95 ++++++++--- .../TelemetryDataLoaderImplTest.java | 39 ++++- 9 files changed, 372 insertions(+), 57 deletions(-) diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java index 4534c88b745..7e5547fc292 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java @@ -42,14 +42,18 @@ public class LiveMeasureDao implements Dao { this.system2 = system2; } - public List selectByComponentUuidsAndMetricUuids(DbSession dbSession, Collection largeComponentUuids, Collection metricUuis) { - if (largeComponentUuids.isEmpty() || metricUuis.isEmpty()) { + public List selectByComponentUuidsAndMetricUuids(DbSession dbSession, Collection largeComponentUuids, Collection metricUuids) { + if (largeComponentUuids.isEmpty() || metricUuids.isEmpty()) { return Collections.emptyList(); } return executeLargeInputs( largeComponentUuids, - componentUuids -> mapper(dbSession).selectByComponentUuidsAndMetricUuids(componentUuids, metricUuis)); + componentUuids -> mapper(dbSession).selectByComponentUuidsAndMetricUuids(componentUuids, metricUuids)); + } + + public List selectForProjectsByMetricUuids(DbSession dbSession, Collection metricUuids) { + return mapper(dbSession).selectForProjectsByMetricUuids(metricUuids); } public void scrollSelectByComponentUuidAndMetricKeys(DbSession dbSession, String componentUuid, Collection metricKeys, ResultHandler handler) { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java index c7bd47c479a..9d2765d89e3 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java @@ -31,6 +31,9 @@ public interface LiveMeasureMapper { @Param("componentUuids") Collection componentUuids, @Param("metricUuids") Collection metricUuids); + List selectForProjectsByMetricUuids( + @Param("metricUuids") Collection metricUuids); + List selectByComponentUuidsAndMetricKeys( @Param("componentUuids") Collection componentUuids, @Param("metricKeys") Collection metricKeys); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml index efdb50c965c..03d57e505bc 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml @@ -23,6 +23,16 @@ + +