Skip to content

Commit

Permalink
Merge pull request #382 from OpenElements/filterbybranch
Browse files Browse the repository at this point in the history
Filter measurements by branch
  • Loading branch information
Ndacyayisenga-droid committed May 19, 2024
2 parents 7ca92fd + 7c9080b commit e6903c6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
Expand Down Expand Up @@ -123,4 +119,10 @@ List<Measurement> findByQuery(@RequestParam final String benchmarkId,
return measurements;
}
}

@GetMapping("/{benchmarkId}/branches")
public List<String> getGitBranchesForBenchmark(@PathVariable String benchmarkId) {
return measurementService.getBranchesForBenchmark(benchmarkId);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ public interface MeasurementRepository extends EntityWithTenantRepository<Measur
@NonNull
@Query("SELECT m FROM Measurement m WHERE m.benchmarkId = ?1 ORDER BY m.timestamp DESC limit 1")
Optional<MeasurementEntity> findLast(final UUID benchmarkId);

@NonNull
@Query("SELECT DISTINCT m.metadata.gitBranch FROM Measurement m WHERE m.benchmarkId = ?1")
List<String> findDistinctBranchesByBenchmarkId(UUID benchmarkId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,10 @@ public DateTimePeriode getPeriode(@NonNull final UUID benchmarkId) {
.orElseThrow(() -> new IllegalArgumentException("No measurement for benchmark " + benchmarkId));
return DateTimePeriode.between(start, end);
}

@NonNull
public List<String> getBranchesForBenchmark(@NonNull final String benchmarkId) {
Objects.requireNonNull(benchmarkId, "benchmarkId must not be null");
return measurementRepository.findDistinctBranchesByBenchmarkId(UUID.fromString(benchmarkId));
}
}

0 comments on commit e6903c6

Please sign in to comment.