Skip to content

Commit

Permalink
fix(build metrics): clean up route & controller on exit (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
DekusDenial authored and jithine committed Apr 11, 2019
1 parent bc0ba12 commit 3c06338
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
15 changes: 15 additions & 0 deletions app/pipeline/metrics/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ export default Controller.extend({
);
}
}),
init() {
this._super(...arguments);
this.reinit();
},
reinit() {
// clear all those flags b/c this is a controller
this.set('selectedRange', '1wk');
this.set('inTrendlineView', false);
this.set('isUTC', false);

// safety step to release references
this.set(this.get('eventsChartName'), null);
this.set(this.get('buildsChartName'), null);
this.set(this.get('stepsChartName'), null);
},
/**
* Memoized range generator
* Generator code borrowed from MDN:
Expand Down
14 changes: 6 additions & 8 deletions app/pipeline/metrics/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import timeRange from 'screwdriver-ui/utils/time-range';
export default Route.extend({
init() {
this._super(...arguments);

this.reinit();
},
reinit() {
const { startTime, endTime } = timeRange(new Date(), '1wk');

// these are used for querying, so they are in ISO8601 format
Expand All @@ -28,12 +30,8 @@ export default Route.extend({
this.set('fetchJob', false);
},
deactivate() {
const controller = this.controllerFor('pipeline.metrics');

// safety step to release references
controller.set('eventsChart', null);
controller.set('buildsChart', null);
controller.set('stepsChart', null);
this.reinit();
this.controllerFor('pipeline.metrics').reinit();
},
model() {
const controller = this.controllerFor('pipeline.metrics');
Expand Down Expand Up @@ -231,7 +229,7 @@ export default Route.extend({
this.refresh();
},
filterSuccessOnly() {
this.set('successOnly', !this.get('successOnly'));
this.toggleProperty('successOnly');
this.refresh();
}
}
Expand Down
2 changes: 0 additions & 2 deletions app/pipeline/metrics/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
clickOpens=true
dateFormat='m/d/Y'
date=customRange
flatpickrRef=flatpickrRef
getFlatpickrRef=(action (mut flatpickrRef))
locale="en"
mode="range"
onChange=(action (mut dateValues))
Expand Down

0 comments on commit 3c06338

Please sign in to comment.