Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #395 from hpcloud/613-trigger-build-clears-deliver…
Browse files Browse the repository at this point in the history
…y-logs-events

613 trigger build clears delivery logs events
  • Loading branch information
sean-sq-chen committed Jun 22, 2016
2 parents 4b4a5cc + 68b8e70 commit b2bbf1b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
this.$q = $q;
this.moment = moment;
this.$log = $log;
this.$scope = $scope;

var that = this;
var promise;
Expand Down Expand Up @@ -109,10 +110,6 @@
that.hasProject = 'error';
});

that.execWatch = $scope.$watch(function() { return that.displayedExecutions; }, function(visibleExecutions) {
that.updateVisibleExecutions(visibleExecutions);
});

}

angular.extend(ApplicationDeliveryLogsController.prototype, {
Expand Down Expand Up @@ -196,7 +193,20 @@
*/
updateData: function() {
var that = this;

// Reset/init the locally cached events and start watching the visible executions (only events for executions that
// are visible will be fetched)
that.eventsPerExecution = {};
// Watch the visible executions. This will internally stop watching if all executions have had their events
// fetched. Also debounce the execution to avoid initialisation flip flop
if (that.execWatch) {
that.execWatch();
}
that.execWatch = that.$scope.$watch(function() {
return that.displayedExecutions;
}, _.debounce(function(visibleExecutions) {
that.updateVisibleExecutions(visibleExecutions);
}, 500));

var promise;
if (this.haveBackend) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,16 @@
describe('dynamic loading of events when execution visible - updateVisibleExecutions', function() {
beforeEach(function() {
createController(true);
controller.eventsPerExecution = {};
// Call updateModel to set up watch, we'll test if this watch is correctly called
spyOn(hceModel, 'getProject').and.callFake(function() {
return project;
});
spyOn(hceModel, 'getPipelineExecutions').and.callFake(function() {
return $q.when();
});
_.set(controller, 'hceModel.data.pipelineExecutions', []);
controller.updateData();
$rootScope.$apply();
});

it('Nothing visible? Nothing to update', function() {
Expand Down Expand Up @@ -725,7 +734,7 @@

});

it('fetch event succeeds, watch not killed', function() {
it('fetch event succeeds, watch should not be killed', function() {
var execution1 = {
id: 'one',
reason: {
Expand Down

0 comments on commit b2bbf1b

Please sign in to comment.