Fix attributes and relatiobships in build

This commit is contained in:
Piotr Sarnacki 2013-02-19 06:36:10 +01:00
parent 8ccd95e0b0
commit 99b9c72e2e
5 changed files with 34 additions and 26 deletions

View File

@ -9,3 +9,15 @@ Travis.BuildController = Ember.Controller.extend
loading: (-> loading: (->
!@get('build.isLoaded') !@get('build.isLoaded')
).property('build.isLoaded') ).property('build.isLoaded')
urlGithubCommit: (->
Travis.Urls.githubCommit(@get('repo.slug'), @get('commit.sha'))
).property('repo.slug', 'commit.sha')
urlAuthor: (->
Travis.Urls.email(@get('commit.authorEmail'))
).property('commit.authorEmail')
urlCommitter: (->
Travis.Urls.email(@get('commit.committerEmail'))
).property('commit.committerEmail')

View File

@ -2,32 +2,33 @@ require 'travis/model'
@Travis.Build = Travis.Model.extend Travis.DurationCalculations, @Travis.Build = Travis.Model.extend Travis.DurationCalculations,
eventType: DS.attr('string') eventType: DS.attr('string')
repoId: DS.attr('number', key: 'repository_id') repoId: DS.attr('number')
commitId: DS.attr('number') commitId: DS.attr('number')
state: DS.attr('string') state: DS.attr('string')
number: DS.attr('number') number: DS.attr('number')
branch: DS.attr('string') branch: DS.attr('string')
message: DS.attr('string') message: DS.attr('string')
_duration: DS.attr('number', key: 'duration') _duration: DS.attr('number')
startedAt: DS.attr('string', key: 'started_at') _config: DS.attr('string')
finishedAt: DS.attr('string', key: 'finished_at') startedAt: DS.attr('string')
finishedAt: DS.attr('string')
repo: DS.belongsTo('Travis.Repo', key: 'repository_id') repo: DS.belongsTo('Travis.Repo')
commit: DS.belongsTo('Travis.Commit') commit: DS.belongsTo('Travis.Commit')
jobs: DS.hasMany('Travis.Job', key: 'job_ids') jobs: DS.hasMany('Travis.Job')
config: (-> config: (->
Travis.Helpers.compact(@get('data.config')) Travis.Helpers.compact(@get('_config'))
).property('data.config') ).property('_config')
isPullRequest: (-> isPullRequest: (->
@get('eventType') == 'pull_request' @get('eventType') == 'pull_request'
).property('eventType') ).property('eventType')
isMatrix: (-> isMatrix: (->
@get('data.job_ids.length') > 1 @get('jobs.length') > 1
).property('data.job_ids.length') ).property('jobs.length')
isFinished: (-> isFinished: (->
@get('state') in ['passed', 'failed', 'errored', 'canceled'] @get('state') in ['passed', 'failed', 'errored', 'canceled']

View File

@ -40,3 +40,13 @@ Travis.RestAdapter = DS.RESTAdapter.extend
@_super.apply this, arguments @_super.apply this, arguments
Travis.RestAdapter.map 'Travis.Commit', {} Travis.RestAdapter.map 'Travis.Commit', {}
Travis.RestAdapter.map 'Travis.Build', {
repoId: { key: 'repository_id' }
repo: { key: 'repository_id' }
_duration: { key: 'duration' }
jobs: { key: 'job_ids' }
_config: { key: 'config' }
}
Travis.RestAdapter.map 'Travis.Repo', {}

View File

@ -6,9 +6,7 @@
<dt>{{t builds.name}}</dt> <dt>{{t builds.name}}</dt>
<dd class="number"> <dd class="number">
<span class="status"></span> <span class="status"></span>
{{#with build}} {{#linkTo build repo build}}{{build.number}}{{/linkTo}}
<a {{action showBuild repo this href=true}}>{{number}}</a>
{{/with}}
</dd> </dd>
<dt>{{t builds.state}}</dt> <dt>{{t builds.state}}</dt>
<dd class="state">{{capitalize build.state}}</dd> <dd class="state">{{capitalize build.state}}</dd>

View File

@ -57,16 +57,3 @@
color: (-> color: (->
Travis.Helpers.colorForState(@get('build.state')) Travis.Helpers.colorForState(@get('build.state'))
).property('build.state') ).property('build.state')
urlGithubCommit: (->
Travis.Urls.githubCommit(@get('repo.slug'), @get('commit.sha'))
).property('repo.slug', 'commit.sha')
urlAuthor: (->
Travis.Urls.email(@get('commit.authorEmail'))
).property('commit.authorEmail')
urlCommitter: (->
Travis.Urls.email(@get('commit.committerEmail'))
).property('commit.committerEmail')