Skip to content

Commit

Permalink
fix(web): Return correct num executions with dual redis
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert committed Oct 5, 2017
1 parent 333af99 commit f63d99b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class TaskController {
.toInstant()
.toEpochMilli()

executionRepository
def orchestrations = executionRepository
.retrieveOrchestrationsForApplication(application, executionCriteria)
.filter({ Orchestration orchestration -> !orchestration.startTime || (orchestration.startTime > startTimeCutoff) })
.map({ Orchestration orchestration -> convert(orchestration) })
Expand All @@ -101,6 +101,8 @@ class TaskController {
.toBlocking()
.single()
.sort(startTimeOrId)

orchestrations.subList(0, Math.min(orchestrations.size(), limit))
}

@PreAuthorize("@fiatPermissionEvaluator.storeWholePermission()")
Expand Down Expand Up @@ -169,7 +171,7 @@ class TaskController {
executionRepository.retrievePipelinesForPipelineConfigId(it, executionCriteria)
}).subscribeOn(Schedulers.io()).toList().toBlocking().single().sort(startTimeOrId)

return filterPipelinesByHistoryCutoff(allPipelines)
return filterPipelinesByHistoryCutoff(allPipelines, limit)
}

@PostAuthorize("hasPermission(returnObject.application, 'APPLICATION', 'READ')")
Expand Down Expand Up @@ -322,10 +324,10 @@ class TaskController {
executionRepository.retrievePipelinesForPipelineConfigId(it, executionCriteria)
}).subscribeOn(Schedulers.io()).toList().toBlocking().single().sort(startTimeOrId)

return filterPipelinesByHistoryCutoff(allPipelines)
return filterPipelinesByHistoryCutoff(allPipelines, limit)
}

private List<Pipeline> filterPipelinesByHistoryCutoff(List<Pipeline> pipelines) {
private List<Pipeline> filterPipelinesByHistoryCutoff(List<Pipeline> pipelines, int limit) {
// TODO-AJ The eventual goal is to return `allPipelines` without the need to group + filter below (WIP)
def cutoffTime = (new Date(clock.millis()) - daysOfExecutionHistory).time

Expand All @@ -343,7 +345,7 @@ class TaskController {
recentPipelines = sortedPipelinesGroup[0..upperBounds]
}

pipelinesSatisfyingCutoff.addAll(recentPipelines)
pipelinesSatisfyingCutoff.addAll(recentPipelines.subList(0, Math.min(recentPipelines.size(), limit)))
}

return pipelinesSatisfyingCutoff.sort(startTimeOrId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class TaskControllerSpec extends Specification {
List results = new ObjectMapper().readValue(response.contentAsString, List)

then:
results.id == ['not-started-2', 'not-started-1', 'newer-2', 'newer-1']
results.id == ['newer-2', 'newer-1']
}

void 'should update existing stage context'() {
Expand Down

0 comments on commit f63d99b

Please sign in to comment.