Search in sources :

Example 1 with SnapshotQuery

use of org.sonar.db.component.SnapshotQuery in project sonarqube by SonarSource.

the class SearchHistoryAction method searchAnalyses.

private List<SnapshotDto> searchAnalyses(DbSession dbSession, SearchHistoryRequest request, ComponentDto component) {
    SnapshotQuery dbQuery = new SnapshotQuery().setComponentUuid(component.projectUuid()).setStatus(STATUS_PROCESSED).setSort(SORT_FIELD.BY_DATE, SORT_ORDER.ASC);
    ofNullable(request.getFrom()).ifPresent(from -> dbQuery.setCreatedAfter(parseStartingDateOrDateTime(from).getTime()));
    ofNullable(request.getTo()).ifPresent(to -> dbQuery.setCreatedBefore(parseEndingDateOrDateTime(to).getTime() + 1_000L));
    return dbClient.snapshotDao().selectAnalysesByQuery(dbSession, dbQuery);
}
Also used : SnapshotQuery(org.sonar.db.component.SnapshotQuery)

Example 2 with SnapshotQuery

use of org.sonar.db.component.SnapshotQuery in project sonarqube by SonarSource.

the class SearchAction method addAnalyses.

private void addAnalyses(SearchData.Builder data) {
    SnapshotQuery dbQuery = new SnapshotQuery().setComponentUuid(data.getProject().uuid()).setStatus(SnapshotDto.STATUS_PROCESSED).setSort(BY_DATE, DESC);
    ofNullable(data.getRequest().getFrom()).ifPresent(from -> dbQuery.setCreatedAfter(parseStartingDateOrDateTime(from).getTime()));
    ofNullable(data.getRequest().getTo()).ifPresent(to -> dbQuery.setCreatedBefore(parseEndingDateOrDateTime(to).getTime() + 1_000L));
    List<SnapshotDto> snapshotDtos = dbClient.snapshotDao().selectAnalysesByQuery(data.getDbSession(), dbQuery);
    var detectedCIs = dbClient.analysisPropertiesDao().selectByKeyAndAnalysisUuids(data.getDbSession(), CorePropertyDefinitions.SONAR_ANALYSIS_DETECTEDCI, snapshotDtos.stream().map(SnapshotDto::getUuid).collect(Collectors.toList()));
    data.setAnalyses(snapshotDtos);
    data.setDetectedCIs(detectedCIs);
}
Also used : SnapshotQuery(org.sonar.db.component.SnapshotQuery) SnapshotDto(org.sonar.db.component.SnapshotDto)

Aggregations

SnapshotQuery (org.sonar.db.component.SnapshotQuery)2 SnapshotDto (org.sonar.db.component.SnapshotDto)1