Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter measurements by branch #382

Merged
merged 3 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
}
Loading