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: (->
!@get('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,
eventType: DS.attr('string')
repoId: DS.attr('number', key: 'repository_id')
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', key: 'duration')
startedAt: DS.attr('string', key: 'started_at')
finishedAt: DS.attr('string', key: 'finished_at')
_duration: DS.attr('number')
_config: DS.attr('string')
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')
jobs: DS.hasMany('Travis.Job', key: 'job_ids')
jobs: DS.hasMany('Travis.Job')
config: (->
Travis.Helpers.compact(@get('data.config'))
).property('data.config')
Travis.Helpers.compact(@get('_config'))
).property('_config')
isPullRequest: (->
@get('eventType') == 'pull_request'
).property('eventType')
isMatrix: (->
@get('data.job_ids.length') > 1
).property('data.job_ids.length')
@get('jobs.length') > 1
).property('jobs.length')
isFinished: (->
@get('state') in ['passed', 'failed', 'errored', 'canceled']

View File

@ -40,3 +40,13 @@ Travis.RestAdapter = DS.RESTAdapter.extend
@_super.apply this, arguments
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>
<dd class="number">
<span class="status"></span>
{{#with build}}
<a {{action showBuild repo this href=true}}>{{number}}</a>
{{/with}}
{{#linkTo build repo build}}{{build.number}}{{/linkTo}}
</dd>
<dt>{{t builds.state}}</dt>
<dd class="state">{{capitalize build.state}}</dd>

View File

@ -57,16 +57,3 @@
color: (->
Travis.Helpers.colorForState(@get('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')