trying some api things

This commit is contained in:
Lisa Passing 2015-05-07 12:40:32 +02:00
parent d08e70f6cf
commit 275f8f14b2

View File

@ -7,22 +7,24 @@ Route = TravisRoute.extend
filter: { replace: true }
model: ->
apiEndpoint = config.apiEndpoint
$.ajax(apiEndpoint + '/v3/repos?repository.active=true', {
console.log(@auth)
# $.ajax(apiEndpoint + '/v3/repos?repository.active=true', {
$.ajax(apiEndpoint + '/v3/#{params.owner}?include=user.repositories,organization.repositories,build.commit', {
headers: {
Authorization: 'token ' + @auth.token()
}
}).then (response) ->
response.repositories.sortBy('last_build.finished_at').filter( (repo) ->
repo.last_build
).sort( (a, b) ->
if !a.last_build.finished_at || a.last_build.finished_at > b.last_build.finished_at
return -1
else if !b.last_build.finished_at || b.last_build.finished_at > a.last_build.finished_at
return 1
else
return 0
).map( (repo) ->
Ember.Object.create(repo)
)
# response.repositories.sortBy('last_build.finished_at').filter( (repo) ->
# repo.last_build
# ).sort( (a, b) ->
# if !a.last_build.finished_at || a.last_build.finished_at > b.last_build.finished_at
# return -1
# else if !b.last_build.finished_at || b.last_build.finished_at > a.last_build.finished_at
# return 1
# else
# return 0
# ).map( (repo) ->
# Ember.Object.create(repo)
# )
`export default Route`