diff options
author | Jacek <jacek.poreda@sonarsource.com> | 2020-03-20 15:22:33 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-03-30 20:03:43 +0000 |
commit | 6c65627048020ee3069dc8f47b5662c2ef1e2a04 (patch) | |
tree | e8b7aa0cdf77645521918378d33636c18fea142b /server/sonar-server-common | |
parent | 50a9f8a09df69a95554f4b067136ca1a5218d880 (diff) | |
download | sonarqube-6c65627048020ee3069dc8f47b5662c2ef1e2a04.tar.gz sonarqube-6c65627048020ee3069dc8f47b5662c2ef1e2a04.zip |
SONAR-13204 remove global() aggr in project_measure ES search queries
Diffstat (limited to 'server/sonar-server-common')
2 files changed, 25 insertions, 21 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java b/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java index 431e66d31de..73ba62e3c62 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java @@ -35,19 +35,19 @@ import static org.sonar.api.measures.Metric.Level.ERROR; import static org.sonar.api.measures.Metric.Level.OK; import static org.sonar.api.measures.Metric.Level.WARN; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_ANALYSED_AT; -import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_DISTRIB_LANGUAGE; -import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_DISTRIB_NCLOC; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_KEY; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_LANGUAGES; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_MEASURES; -import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_MEASURES_KEY; -import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_MEASURES_VALUE; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_NAME; -import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_NCLOC_LANGUAGE_DISTRIBUTION; +import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_NCLOC_DISTRIBUTION; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_ORGANIZATION_UUID; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_QUALITY_GATE_STATUS; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_TAGS; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.FIELD_UUID; +import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.SUB_FIELD_DISTRIB_LANGUAGE; +import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.SUB_FIELD_DISTRIB_NCLOC; +import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.SUB_FIELD_MEASURES_KEY; +import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.SUB_FIELD_MEASURES_VALUE; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.TYPE_PROJECT_MEASURES; public class ProjectMeasuresDoc extends BaseDoc { @@ -119,8 +119,8 @@ public class ProjectMeasuresDoc extends BaseDoc { setMeasures( measures.entrySet().stream() .map(entry -> ImmutableMap.<String, Object>of( - FIELD_MEASURES_KEY, entry.getKey(), - FIELD_MEASURES_VALUE, entry.getValue())) + SUB_FIELD_MEASURES_KEY, entry.getKey(), + SUB_FIELD_MEASURES_VALUE, entry.getValue())) .collect(MoreCollectors.toList())); return this; } @@ -131,11 +131,11 @@ public class ProjectMeasuresDoc extends BaseDoc { } public Collection<Map<String, Object>> getNclocLanguageDistribution() { - return getField(FIELD_NCLOC_LANGUAGE_DISTRIBUTION); + return getField(FIELD_NCLOC_DISTRIBUTION); } public ProjectMeasuresDoc setNclocLanguageDistribution(Collection<Map<String, Object>> distribution) { - setField(FIELD_NCLOC_LANGUAGE_DISTRIBUTION, distribution); + setField(FIELD_NCLOC_DISTRIBUTION, distribution); return this; } @@ -143,8 +143,8 @@ public class ProjectMeasuresDoc extends BaseDoc { setNclocLanguageDistribution( distribution.entrySet().stream() .map(entry -> ImmutableMap.<String, Object>of( - FIELD_DISTRIB_LANGUAGE, entry.getKey(), - FIELD_DISTRIB_NCLOC, entry.getValue())) + SUB_FIELD_DISTRIB_LANGUAGE, entry.getKey(), + SUB_FIELD_DISTRIB_NCLOC, entry.getValue())) .collect(MoreCollectors.toList())); return this; } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexDefinition.java b/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexDefinition.java index 71159a51fe5..447042bacfb 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexDefinition.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexDefinition.java @@ -52,12 +52,16 @@ public class ProjectMeasuresIndexDefinition implements IndexDefinition { public static final String FIELD_QUALITY_GATE_STATUS = "qualityGateStatus"; public static final String FIELD_TAGS = "tags"; public static final String FIELD_MEASURES = "measures"; - public static final String FIELD_MEASURES_KEY = "key"; - public static final String FIELD_MEASURES_VALUE = "value"; + public static final String SUB_FIELD_MEASURES_KEY = "key"; + public static final String SUB_FIELD_MEASURES_VALUE = "value"; + public static final String FIELD_MEASURES_MEASURE_KEY = FIELD_MEASURES + "." + SUB_FIELD_MEASURES_KEY; + public static final String FIELD_MEASURES_MEASURE_VALUE = FIELD_MEASURES + "." + SUB_FIELD_MEASURES_VALUE; public static final String FIELD_LANGUAGES = "languages"; - public static final String FIELD_NCLOC_LANGUAGE_DISTRIBUTION = "nclocLanguageDistribution"; - public static final String FIELD_DISTRIB_LANGUAGE = "language"; - public static final String FIELD_DISTRIB_NCLOC = "ncloc"; + public static final String FIELD_NCLOC_DISTRIBUTION = "nclocLanguageDistribution"; + public static final String SUB_FIELD_DISTRIB_LANGUAGE = "language"; + public static final String SUB_FIELD_DISTRIB_NCLOC = "ncloc"; + public static final String FIELD_NCLOC_DISTRIBUTION_LANGUAGE = FIELD_NCLOC_DISTRIBUTION + "." + SUB_FIELD_DISTRIB_LANGUAGE; + public static final String FIELD_NCLOC_DISTRIBUTION_NCLOC = FIELD_NCLOC_DISTRIBUTION + "." + SUB_FIELD_DISTRIB_NCLOC; private final Configuration config; private final boolean enableSource; @@ -98,12 +102,12 @@ public class ProjectMeasuresIndexDefinition implements IndexDefinition { mapping.keywordFieldBuilder(FIELD_TAGS).build(); mapping.keywordFieldBuilder(FIELD_LANGUAGES).build(); mapping.nestedFieldBuilder(FIELD_MEASURES) - .addKeywordField(FIELD_MEASURES_KEY) - .addDoubleField(FIELD_MEASURES_VALUE) + .addKeywordField(SUB_FIELD_MEASURES_KEY) + .addDoubleField(SUB_FIELD_MEASURES_VALUE) .build(); - mapping.nestedFieldBuilder(FIELD_NCLOC_LANGUAGE_DISTRIBUTION) - .addKeywordField(FIELD_DISTRIB_LANGUAGE) - .addIntegerField(FIELD_DISTRIB_NCLOC) + mapping.nestedFieldBuilder(FIELD_NCLOC_DISTRIBUTION) + .addKeywordField(SUB_FIELD_DISTRIB_LANGUAGE) + .addIntegerField(SUB_FIELD_DISTRIB_NCLOC) .build(); mapping.createDateTimeField(FIELD_ANALYSED_AT); } |