/** * Example: * If Main Branch = 0 LOCs (provisioned but never analyzed) and the "largest long-lived branch" is 120 LOCs, I'm expecting to consider the value 120. * If Main Branch = 100 LOCs and the "largest long-lived branch" is 120 LOCs, I'm expecting to consider the value 120. * If Main Branch = 100 LOCs and the "largest long-lived branch" is 80 LOCs, I'm expecting to consider the value 100. */ public long sumNclocOfBiggestLongLivingBranch(DbSession dbSession, SumNclocDbQuery dbQuery) { Long ncloc = mapper(dbSession).sumNclocOfBiggestLongLivingBranch( NCLOC_KEY, KeyType.BRANCH, BranchType.LONG, dbQuery.getOrganizationUuid(), dbQuery.getOnlyPrivateProjects(), dbQuery.getProjectUuidToExclude()); return ncloc == null ? 0L : ncloc; }
/** * Select measures of: * - one component * - for a list of metrics * - with analysis from a date (inclusive) - optional * - with analysis to a date (exclusive) - optional * * If no constraints on dates, all the history is returned */ public List<MeasureDto> selectPastMeasures(DbSession dbSession, PastMeasureQuery query) { return mapper(dbSession).selectPastMeasuresOnSeveralAnalyses(query); }
public void insert(DbSession session, Collection<MeasureDto> items) { for (MeasureDto item : items) { insert(session, item); } }
@Test public void insertOrUpdate() { // insert LiveMeasureDto dto = newLiveMeasure(); underTest.insertOrUpdate(db.getSession(), dto); verifyPersisted(dto); verifyTableSize(1); // update dto.setValue(dto.getValue() + 1); dto.setVariation(dto.getVariation() + 10); dto.setData(dto.getDataAsString() + "_new"); underTest.insertOrUpdate(db.getSession(), dto); verifyPersisted(dto); verifyTableSize(1); }
private void insertMeasure(String id, String analysisUuid, String componentUuid, int metricId) { MeasureDto measure = MeasureTesting.newMeasure() .setAnalysisUuid(analysisUuid) .setComponentUuid(componentUuid) .setMetricId(metricId) // as ids can't be forced when inserting measures, the field "data" // is used to store a virtual id. It is used then in assertions. .setData(id); db.getDbClient().measureDao().insert(db.getSession(), measure); }
private static MeasureDto createMeasureDto(int metricId, String componentUuid, String analysisUuid) { return new MeasureDto() .setComponentUuid(componentUuid) .setAnalysisUuid(analysisUuid) .setData(SOME_DATA) .setMetricId(metricId); } }
private long computeNcloc() { try (DbSession dbSession = dbClient.openSession(false)) { SumNclocDbQuery query = SumNclocDbQuery.builder() .setOnlyPrivateProjects(false) .setOrganizationUuid(defaultOrganizationProvider.get().getUuid()) .build(); return dbClient.liveMeasureDao().sumNclocOfBiggestLongLivingBranch(dbSession, query); } } }
private static MeasureDto newTextMeasure(String data) { return new MeasureDto().setData(data); } }
@Override @CheckForNull protected ProjectMeasures doNext() { if (!projects.hasNext()) { return null; } Project project = projects.next(); Measures measures = selectMeasures(project.getUuid()); return new ProjectMeasures(project, measures); }
public void selectTreeByQuery(DbSession dbSession, ComponentDto baseComponent, MeasureTreeQuery query, ResultHandler<LiveMeasureDto> resultHandler) { if (query.returnsEmpty()) { return; } mapper(dbSession).selectTreeByQuery(query, baseComponent.uuid(), query.getUuidPath(baseComponent), resultHandler); }
private void insertMeasure(double value, ComponentDto componentDto, MetricDto metric) { db.measures().insertLiveMeasure(componentDto, metric, m -> m.setValue(value)); }
public Optional<MeasureDto> selectMeasure(DbSession dbSession, String analysisUuid, String componentUuid, String metricKey) { return Optional.ofNullable(mapper(dbSession).selectMeasure(analysisUuid, componentUuid, metricKey)); }
public MeasureQuery build() { return new MeasureQuery(this); } }
public int deleteByComponentUuidExcludingMetricIds(DbSession dbSession, String componentUuid, List<Integer> excludedMetricIds) { return mapper(dbSession).deleteByComponentUuidExcludingMetricIds(componentUuid, excludedMetricIds); }
public MeasureTreeQuery build() { return new MeasureTreeQuery(this); } }
public static Builder builder() { return new Builder(); }
public Optional<LiveMeasureDto> selectByComponentUuidAndMetricKey(DbSession dbSession, String componentUuid, String metricKey) { LiveMeasureDto liveMeasureDto = mapper(dbSession).selectByComponentUuidAndMetricKey(componentUuid, metricKey); return Optional.ofNullable(liveMeasureDto); }
private Map<String, ProjectMeasures> createResultSetAndReturnDocsById() { return createResultSetAndReturnDocsById(null); }
static MeasureQuery copyWithSubsetOfProjectUuids(MeasureQuery query, Collection<String> projectUuids) { return new MeasureQuery(query.analysisUuid, projectUuids, query.componentUuids, query.metricIds, query.metricKeys); }