Skip to content

Commit

Permalink
finish?
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMGranger committed Feb 8, 2024
1 parent d65c558 commit a78f6ff
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/api/pelorus/org/SoftwareDeliveryPerformanceApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ static String byAppData(AppRangeAt args) {

private static class DeploymentFrequencyQuery {
// TODO: where does the `@` go?
static final String DEPLOYMENT_FREQUENCY = "count (count_over_time (deploy_timestamp [%s]))";
static final String DEPLOYMENT_FREQUENCY = "count (count_over_time (deploy_timestamp [%s] @ %s))";
static final String BY_APP = "count (count_over_time (deploy_timestamp{app=~'.*%s.*'}[%s] @ %s))";
static final String BY_APP_OFFSET = "count (count_over_time (deploy_timestamp{app=~'.*%1$s.*'}[%2$s] @ %3$s offset %2$s))";
static final String BY_APP_DATA = "deploy_timestamp{app=~'.*%s.*'}[%s] @ %s";

static String general(String range) {
return DEPLOYMENT_FREQUENCY.formatted(range);
static String general(RangeAt args) {
return DEPLOYMENT_FREQUENCY.formatted(args.range, args.at);
}

static String byApp(AppRangeAt args) {
Expand Down Expand Up @@ -226,8 +226,10 @@ public List<LeadTimeData> queryLeadTimeforChangeDataByApp(String app, @QueryPara
@GET
@Path("/deployment_frequency")
@Produces(MediaType.APPLICATION_JSON)
public HTTPQueryResult queryDeploymentFrequency(@QueryParam("range") String range) {
HTTPQueryResult results = logAndQuery("DEPLOYMENT_FREQUENCY", DeploymentFrequencyQuery.general(range));
public HTTPQueryResult queryDeploymentFrequency(@QueryParam("range") String range,
@QueryParam("start") String start) {
HTTPQueryResult results = logAndQuery("DEPLOYMENT_FREQUENCY",
DeploymentFrequencyQuery.general(RangeAt.builder().range(range).at(start).build()));
return results;
}

Expand Down Expand Up @@ -330,11 +332,13 @@ public List<MeanTimeToRestoreData> queryLeadMeanTimeToRestoreDataByApp(String ap
@GET
@Path("/change_failure_rate/{app}")
@Produces(MediaType.APPLICATION_JSON)
public ChangeFailureRate queryChangeFailureRateByApp(String app, @QueryParam("range") String range, @QueryParam("start") String start) {
public ChangeFailureRate queryChangeFailureRateByApp(String app, @QueryParam("range") String range,
@QueryParam("start") String start) {
final AppRangeAt queryArgs = AppRangeAt.builder().app(app).range(range).at(start).build();

HTTPQueryResult results = logAndQuery("CHANGE_FAILURE_RATE_BY_APP", ChangeFailureRateQuery.byApp(queryArgs));
HTTPQueryResult offset = logAndQuery("CHANGE_FAILURE_RATE_BY_APP_OFFSET", ChangeFailureRateQuery.byAppOfsset(queryArgs));
HTTPQueryResult offset = logAndQuery("CHANGE_FAILURE_RATE_BY_APP_OFFSET",
ChangeFailureRateQuery.byAppOfsset(queryArgs));

try {
return new ChangeFailureRate(results.data().result().get(0).value().value(),
Expand Down

0 comments on commit a78f6ff

Please sign in to comment.