
This was causing the log to not refresh sometimes when switching from
one repo to another, I'm reverting for now, we will have to have another
look.
This reverts commit 2e8b74160c
.
Conflicts:
assets/scripts/app/controllers/build.coffee
assets/scripts/app/models/build.coffee
assets/scripts/app/templates/builds/show.hbs
assets/scripts/app/views/log.coffee
assets/scripts/vendor/log.js
85 lines
2.3 KiB
CoffeeScript
85 lines
2.3 KiB
CoffeeScript
require 'travis/model'
|
|
|
|
@Travis.Build = Travis.Model.extend Travis.DurationCalculations,
|
|
eventType: DS.attr('string')
|
|
repoId: DS.attr('number')
|
|
commitId: DS.attr('number')
|
|
|
|
state: DS.attr('string')
|
|
number: DS.attr('number')
|
|
branch: DS.attr('string')
|
|
message: DS.attr('string')
|
|
_duration: DS.attr('number')
|
|
_config: DS.attr('object')
|
|
startedAt: DS.attr('string')
|
|
finishedAt: DS.attr('string')
|
|
|
|
repo: DS.belongsTo('Travis.Repo')
|
|
commit: DS.belongsTo('Travis.Commit')
|
|
jobs: DS.hasMany('Travis.Job')
|
|
|
|
config: (->
|
|
Travis.Helpers.compact(@get('_config'))
|
|
).property('_config')
|
|
|
|
isPullRequest: (->
|
|
@get('eventType') == 'pull_request'
|
|
).property('eventType')
|
|
|
|
isMatrix: (->
|
|
@get('jobs.length') > 1
|
|
).property('jobs.length')
|
|
|
|
isFinished: (->
|
|
@get('state') in ['passed', 'failed', 'errored', 'canceled']
|
|
).property('state')
|
|
|
|
requiredJobs: (->
|
|
@get('jobs').filter (data) -> !data.get('allowFailure')
|
|
).property('jobs.@each.allowFailure')
|
|
|
|
allowedFailureJobs: (->
|
|
@get('jobs').filter (data) -> data.get('allowFailure')
|
|
).property('jobs.@each.allowFailure')
|
|
|
|
configKeys: (->
|
|
return [] unless config = @get('config')
|
|
keys = $.intersect($.keys(config), Travis.CONFIG_KEYS)
|
|
headers = (I18n.t(key) for key in ['build.job', 'build.duration', 'build.finished_at'])
|
|
$.map(headers.concat(keys), (key) -> return $.camelize(key))
|
|
).property('config')
|
|
|
|
canCancel: (->
|
|
@get('state') == 'created' # TODO
|
|
).property('state')
|
|
|
|
cancel: (->
|
|
Travis.ajax.post "/builds/#{@get('id')}", _method: 'delete'
|
|
)
|
|
|
|
requeue: ->
|
|
Travis.ajax.post '/requests', build_id: @get('id')
|
|
|
|
isAttributeLoaded: (key) ->
|
|
if ['_duration', 'finishedAt'].contains(key) && !@get('isFinished')
|
|
return true
|
|
else
|
|
@_super(key)
|
|
|
|
|
|
@Travis.Build.reopenClass
|
|
byRepoId: (id, parameters) ->
|
|
@find($.extend(parameters || {}, repository_id: id))
|
|
|
|
branches: (options) ->
|
|
@find repository_id: options.repoId, branches: true
|
|
|
|
olderThanNumber: (id, build_number, type) ->
|
|
console.log type
|
|
# TODO fix this api and use some kind of pagination scheme
|
|
options = { repository_id: id, after_number: build_number }
|
|
if type?
|
|
options.event_type = type.replace(/s$/, '') # poor man's singularize
|
|
|
|
@find(options)
|