Skip to content

Commit e6903c6

Browse files
Merge pull request #382 from OpenElements/filterbybranch
Filter measurements by branch
2 parents 7ca92fd + 7c9080b commit e6903c6

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

server/src/main/java/com/openelements/benchscape/server/store/endpoints/MeasurementEndpoint.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121
import java.util.Optional;
2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.format.annotation.DateTimeFormat;
24-
import org.springframework.web.bind.annotation.CrossOrigin;
25-
import org.springframework.web.bind.annotation.GetMapping;
26-
import org.springframework.web.bind.annotation.RequestMapping;
27-
import org.springframework.web.bind.annotation.RequestParam;
28-
import org.springframework.web.bind.annotation.RestController;
24+
import org.springframework.web.bind.annotation.*;
2925

3026
@CrossOrigin
3127
@RestController
@@ -123,4 +119,10 @@ List<Measurement> findByQuery(@RequestParam final String benchmarkId,
123119
return measurements;
124120
}
125121
}
122+
123+
@GetMapping("/{benchmarkId}/branches")
124+
public List<String> getGitBranchesForBenchmark(@PathVariable String benchmarkId) {
125+
return measurementService.getBranchesForBenchmark(benchmarkId);
126+
}
126127
}
128+

server/src/main/java/com/openelements/benchscape/server/store/repositories/MeasurementRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ public interface MeasurementRepository extends EntityWithTenantRepository<Measur
4141
@NonNull
4242
@Query("SELECT m FROM Measurement m WHERE m.benchmarkId = ?1 ORDER BY m.timestamp DESC limit 1")
4343
Optional<MeasurementEntity> findLast(final UUID benchmarkId);
44+
45+
@NonNull
46+
@Query("SELECT DISTINCT m.metadata.gitBranch FROM Measurement m WHERE m.benchmarkId = ?1")
47+
List<String> findDistinctBranchesByBenchmarkId(UUID benchmarkId);
4448
}

server/src/main/java/com/openelements/benchscape/server/store/services/MeasurementService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,10 @@ public DateTimePeriode getPeriode(@NonNull final UUID benchmarkId) {
186186
.orElseThrow(() -> new IllegalArgumentException("No measurement for benchmark " + benchmarkId));
187187
return DateTimePeriode.between(start, end);
188188
}
189+
190+
@NonNull
191+
public List<String> getBranchesForBenchmark(@NonNull final String benchmarkId) {
192+
Objects.requireNonNull(benchmarkId, "benchmarkId must not be null");
193+
return measurementRepository.findDistinctBranchesByBenchmarkId(UUID.fromString(benchmarkId));
194+
}
189195
}

0 commit comments

Comments
 (0)