Update build durations every 5s
Pusher updates usually don't update duration, so it needs to be calculated from startedAt property and current time or finishedAt property.
This commit is contained in:
parent
1512f8d108
commit
071821c1d7
|
@ -3,6 +3,13 @@ Travis.RepositoriesController = Ember.ArrayController.extend
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
@activate('recent')
|
@activate('recent')
|
||||||
|
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
|
||||||
|
|
||||||
|
updateTimes: ->
|
||||||
|
if content = @get('content')
|
||||||
|
content.forEach (r) -> r.updateTimes()
|
||||||
|
|
||||||
|
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
|
||||||
|
|
||||||
activate: (tab, params) ->
|
activate: (tab, params) ->
|
||||||
@set('tab', tab)
|
@set('tab', tab)
|
||||||
|
|
|
@ -4,6 +4,17 @@ Travis.RepositoryController = Travis.Controller.extend
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
@_super('builds', 'build', 'job')
|
@_super('builds', 'build', 'job')
|
||||||
|
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
|
||||||
|
|
||||||
|
updateTimes: ->
|
||||||
|
if builds = @get('builds')
|
||||||
|
builds.forEach (b) -> b.updateTimes()
|
||||||
|
|
||||||
|
if build = @get('build')
|
||||||
|
build.updateTimes()
|
||||||
|
build.get('jobs').forEach (j) -> j.updateTimes()
|
||||||
|
|
||||||
|
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
|
||||||
|
|
||||||
activate: (action, params) ->
|
activate: (action, params) ->
|
||||||
@_unbind()
|
@_unbind()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
require 'models/extensions'
|
||||||
require 'models/artifact'
|
require 'models/artifact'
|
||||||
require 'models/branch'
|
require 'models/branch'
|
||||||
require 'models/build'
|
require 'models/build'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'travis/model'
|
require 'travis/model'
|
||||||
|
|
||||||
@Travis.Build = Travis.Model.extend
|
@Travis.Build = Travis.Model.extend Travis.DurationCalculations,
|
||||||
eventType: DS.attr('string')
|
eventType: DS.attr('string')
|
||||||
repositoryId: DS.attr('number')
|
repositoryId: DS.attr('number')
|
||||||
commitId: DS.attr('number')
|
commitId: DS.attr('number')
|
||||||
|
@ -10,9 +10,9 @@ require 'travis/model'
|
||||||
branch: DS.attr('string')
|
branch: DS.attr('string')
|
||||||
message: DS.attr('string')
|
message: DS.attr('string')
|
||||||
result: DS.attr('number')
|
result: DS.attr('number')
|
||||||
duration: DS.attr('number')
|
_duration: DS.attr('number', key: 'duration')
|
||||||
startedAt: DS.attr('string')
|
startedAt: DS.attr('string', key: 'started_at')
|
||||||
finishedAt: DS.attr('string')
|
finishedAt: DS.attr('string', key: 'finished_at')
|
||||||
|
|
||||||
repository: DS.belongsTo('Travis.Repository')
|
repository: DS.belongsTo('Travis.Repository')
|
||||||
commit: DS.belongsTo('Travis.Commit')
|
commit: DS.belongsTo('Travis.Commit')
|
||||||
|
@ -41,10 +41,6 @@ require 'travis/model'
|
||||||
$.map(headers.concat(keys), (key) -> return $.camelize(key))
|
$.map(headers.concat(keys), (key) -> return $.camelize(key))
|
||||||
).property('config')
|
).property('config')
|
||||||
|
|
||||||
tick: ->
|
|
||||||
@notifyPropertyChange 'duration'
|
|
||||||
@notifyPropertyChange 'finished_at'
|
|
||||||
|
|
||||||
@Travis.Build.reopenClass
|
@Travis.Build.reopenClass
|
||||||
byRepositoryId: (id, parameters) ->
|
byRepositoryId: (id, parameters) ->
|
||||||
@find($.extend(parameters || {}, repository_id: id, orderBy: 'number DESC'))
|
@find($.extend(parameters || {}, repository_id: id, orderBy: 'number DESC'))
|
||||||
|
|
11
assets/javascripts/app/models/extensions.coffee
Normal file
11
assets/javascripts/app/models/extensions.coffee
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Travis.DurationCalculations = Ember.Mixin.create
|
||||||
|
duration: (->
|
||||||
|
if duration = @get('_duration')
|
||||||
|
duration
|
||||||
|
else
|
||||||
|
Travis.Helpers.durationFrom(@get('startedAt'), @get('finishedAt'))
|
||||||
|
).property('_duration', 'finishedAt', 'startedAt')
|
||||||
|
|
||||||
|
updateTimes: ->
|
||||||
|
@notifyPropertyChange '_duration'
|
||||||
|
@notifyPropertyChange 'finished_at'
|
|
@ -1,6 +1,6 @@
|
||||||
require 'travis/model'
|
require 'travis/model'
|
||||||
|
|
||||||
@Travis.Job = Travis.Model.extend
|
@Travis.Job = Travis.Model.extend Travis.DurationCalculations,
|
||||||
repositoryId: DS.attr('number')
|
repositoryId: DS.attr('number')
|
||||||
buildId: DS.attr('number')
|
buildId: DS.attr('number')
|
||||||
commitId: DS.attr('number')
|
commitId: DS.attr('number')
|
||||||
|
@ -10,7 +10,7 @@ require 'travis/model'
|
||||||
state: DS.attr('string')
|
state: DS.attr('string')
|
||||||
number: DS.attr('string')
|
number: DS.attr('string')
|
||||||
result: DS.attr('number')
|
result: DS.attr('number')
|
||||||
duration: DS.attr('number')
|
_duration: DS.attr('number', key: 'duration')
|
||||||
startedAt: DS.attr('string')
|
startedAt: DS.attr('string')
|
||||||
finishedAt: DS.attr('string')
|
finishedAt: DS.attr('string')
|
||||||
allowFailure: DS.attr('boolean', key: 'allow_failure')
|
allowFailure: DS.attr('boolean', key: 'allow_failure')
|
||||||
|
@ -47,10 +47,6 @@ require 'travis/model'
|
||||||
Travis.app.pusher.unsubscribe "job-#{@get('id')}" if @get('state') == 'finished'
|
Travis.app.pusher.unsubscribe "job-#{@get('id')}" if @get('state') == 'finished'
|
||||||
).observes('state')
|
).observes('state')
|
||||||
|
|
||||||
tick: ->
|
|
||||||
@notifyPropertyChange 'duration'
|
|
||||||
@notifyPropertyChange 'finished_at'
|
|
||||||
|
|
||||||
@Travis.Job.reopenClass
|
@Travis.Job.reopenClass
|
||||||
queued: (queue) ->
|
queued: (queue) ->
|
||||||
@find()
|
@find()
|
||||||
|
|
|
@ -59,9 +59,8 @@ require 'travis/model'
|
||||||
select: ->
|
select: ->
|
||||||
Travis.Repository.select(self.get('id'))
|
Travis.Repository.select(self.get('id'))
|
||||||
|
|
||||||
tick: ->
|
updateTimes: ->
|
||||||
@notifyPropertyChange 'lastBuildDuration'
|
@notifyPropertyChange 'lastBuildDuration'
|
||||||
@notifyPropertyChange 'lastBuildFinishedAt'
|
|
||||||
|
|
||||||
@Travis.Repository.reopenClass
|
@Travis.Repository.reopenClass
|
||||||
recent: ->
|
recent: ->
|
||||||
|
|
|
@ -28,7 +28,7 @@ require 'ext/ember/namespace'
|
||||||
{ name: 'spree', display: 'Spree' }
|
{ name: 'spree', display: 'Spree' }
|
||||||
]
|
]
|
||||||
|
|
||||||
INTERVALS: { sponsors: -1, times: -1 }
|
INTERVALS: { sponsors: -1, times: -1, updateTimes: 5000 }
|
||||||
|
|
||||||
run: (attrs) ->
|
run: (attrs) ->
|
||||||
@app = Travis.App.create(attrs || {})
|
@app = Travis.App.create(attrs || {})
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user