Merge pull request #445 from travis-ci/update-finished-at-for-finished-builds
Update time also for finished builds, but only every minute
This commit is contained in:
commit
ac4f5ed193
|
@ -3,6 +3,8 @@ import config from 'travis/config/environment';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
store: Ember.inject.service(),
|
store: Ember.inject.service(),
|
||||||
|
updateTimesService: Ember.inject.service('updateTimes'),
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
if (!Ember.testing) {
|
if (!Ember.testing) {
|
||||||
|
@ -11,11 +13,6 @@ export default Ember.Component.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTimes() {
|
updateTimes() {
|
||||||
var jobs;
|
this.get('updateTimesService').push(this.get('jobs'));
|
||||||
if (jobs = this.get('jobs')) {
|
|
||||||
return jobs.forEach(function(job) {
|
|
||||||
return job.updateTimes();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import config from 'travis/config/environment';
|
||||||
|
|
||||||
export default Ember.Component.extend(Polling, {
|
export default Ember.Component.extend(Polling, {
|
||||||
store: Ember.inject.service(),
|
store: Ember.inject.service(),
|
||||||
|
updateTimesService: Ember.inject.service('updateTimes'),
|
||||||
|
|
||||||
pollHook(store) {
|
pollHook(store) {
|
||||||
return this.get('store').find('job', {});
|
return this.get('store').find('job', {});
|
||||||
|
@ -17,11 +18,6 @@ export default Ember.Component.extend(Polling, {
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTimes() {
|
updateTimes() {
|
||||||
var jobs;
|
this.get('updateTimesService').push(this.get('jobs'));
|
||||||
if (jobs = this.get('jobs')) {
|
|
||||||
return jobs.forEach(function(job) {
|
|
||||||
return job.updateTimes();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import config from 'travis/config/environment';
|
||||||
|
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
|
updateTimesService: Ember.inject.service('updateTimes'),
|
||||||
popup: Ember.inject.service(),
|
popup: Ember.inject.service(),
|
||||||
|
|
||||||
jobController: Ember.inject.controller('job'),
|
jobController: Ember.inject.controller('job'),
|
||||||
|
@ -49,27 +50,16 @@ export default Ember.Controller.extend({
|
||||||
init() {
|
init() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
if (!Ember.testing) {
|
if (!Ember.testing) {
|
||||||
return Visibility.every(this.config.intervals.updateTimes, this.updateTimes.bind(this));
|
Visibility.every(this.config.intervals.updateTimes, this.updateTimes.bind(this));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTimes() {
|
updateTimes() {
|
||||||
return Ember.run(this, function() {
|
let updateTimesService = this.get('updateTimesService');
|
||||||
var build, builds, jobs;
|
|
||||||
if (builds = this.get('builds')) {
|
updateTimesService.push(this.get('build'));
|
||||||
builds.forEach(function(b) {
|
updateTimesService.push(this.get('builds'));
|
||||||
return b.updateTimes();
|
updateTimesService.push(this.get('jobs'));
|
||||||
});
|
|
||||||
}
|
|
||||||
if (build = this.get('build')) {
|
|
||||||
build.updateTimes();
|
|
||||||
}
|
|
||||||
if (build && (jobs = build.get('jobs'))) {
|
|
||||||
return jobs.forEach(function(j) {
|
|
||||||
return j.updateTimes();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivate() {
|
deactivate() {
|
||||||
|
|
|
@ -51,6 +51,7 @@ var sortCallback = function(repo1, repo2) {
|
||||||
|
|
||||||
var Controller = Ember.Controller.extend({
|
var Controller = Ember.Controller.extend({
|
||||||
ajax: Ember.inject.service(),
|
ajax: Ember.inject.service(),
|
||||||
|
updateTimesService: Ember.inject.service('updateTimes'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
activate: function(name) {
|
activate: function(name) {
|
||||||
|
@ -97,7 +98,7 @@ var Controller = Ember.Controller.extend({
|
||||||
init() {
|
init() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
if (!Ember.testing) {
|
if (!Ember.testing) {
|
||||||
return Visibility.every(this.config.intervals.updateTimes, this.updateTimes.bind(this));
|
Visibility.every(this.config.intervals.updateTimes, this.updateTimes.bind(this));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -133,12 +134,13 @@ var Controller = Ember.Controller.extend({
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
updateTimes() {
|
updateTimes() {
|
||||||
var repos;
|
let records = this.get('repos');
|
||||||
if (repos = this.get('repos')) {
|
|
||||||
return repos.forEach(function(r) {
|
if(Config.useV3API) {
|
||||||
return r.updateTimes();
|
let callback = (record) => { return record.get('lastBuild'); };
|
||||||
});
|
records = records.filter(callback).map(callback);
|
||||||
}
|
}
|
||||||
|
this.get('updateTimesService').push(records);
|
||||||
},
|
},
|
||||||
|
|
||||||
activate(tab, params) {
|
activate(tab, params) {
|
||||||
|
|
|
@ -55,7 +55,12 @@ if (Config.useV3API) {
|
||||||
duration = durationFromHelper(this.get('lastBuildStartedAt'), this.get('lastBuildFinishedAt'));
|
duration = durationFromHelper(this.get('lastBuildStartedAt'), this.get('lastBuildFinishedAt'));
|
||||||
}
|
}
|
||||||
return duration;
|
return duration;
|
||||||
}.property('_lastBuildDuration', 'lastBuildStartedAt', 'lastBuildFinishedAt')
|
}.property('_lastBuildDuration', 'lastBuildStartedAt', 'lastBuildFinishedAt'),
|
||||||
|
|
||||||
|
isFinished: function() {
|
||||||
|
let state = this.get('lastBuildState');
|
||||||
|
return ['passed', 'failed', 'errored', 'canceled'].contains(state);
|
||||||
|
}.property('lastBuildState')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
54
app/services/update-times.js
Normal file
54
app/services/update-times.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
import Ember from 'ember';
|
||||||
|
import Config from 'travis/config/environment';
|
||||||
|
|
||||||
|
export default Ember.Service.extend({
|
||||||
|
records: [],
|
||||||
|
allowFinishedBuilds: false,
|
||||||
|
|
||||||
|
init() {
|
||||||
|
Visibility.every(Config.intervals.updateTimes, this.updateTimes.bind(this));
|
||||||
|
setInterval(this.resetAllowFinishedBuilds.bind(this), 60000);
|
||||||
|
|
||||||
|
return this._super(...arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
resetAllowFinishedBuilds() {
|
||||||
|
this.set('allowFinishedBuilds', true);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateTimes() {
|
||||||
|
let records = this.get('records');
|
||||||
|
|
||||||
|
records.filter((record) => {
|
||||||
|
return this.get('allowFinishedBuilds') || !record.get('isFinished');
|
||||||
|
}).forEach((record) => {
|
||||||
|
record.updateTimes();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.set('records', []);
|
||||||
|
|
||||||
|
if(this.get('allowFinishedBuilds')) {
|
||||||
|
this.set('allowFinishedBuilds', false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
pushObject(record) {
|
||||||
|
let records = this.get('records');
|
||||||
|
|
||||||
|
if(!records.contains(record)) {
|
||||||
|
records.pushObject(record);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
push(model) {
|
||||||
|
if(!model) { return; }
|
||||||
|
|
||||||
|
if(model.forEach) {
|
||||||
|
model.forEach( (element) => {
|
||||||
|
this.pushObject(element);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.pushObject(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -14,9 +14,7 @@ export default Ember.Mixin.create({
|
||||||
}.property('_duration', 'finishedAt', 'startedAt', 'notStarted', '_finishedAt', '_startedAt'),
|
}.property('_duration', 'finishedAt', 'startedAt', 'notStarted', '_finishedAt', '_startedAt'),
|
||||||
|
|
||||||
updateTimes() {
|
updateTimes() {
|
||||||
if (!this.get('isFinished')) {
|
this.notifyPropertyChange('duration');
|
||||||
this.notifyPropertyChange('duration');
|
return this.notifyPropertyChange('finishedAt');
|
||||||
return this.notifyPropertyChange('finishedAt');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user