Bring better sortOrder for my repos back

This commit is contained in:
Piotr Sarnacki 2015-04-08 14:08:02 +02:00
parent 708c738e5d
commit cbbd555fdd
2 changed files with 10 additions and 2 deletions

View File

@ -107,7 +107,7 @@ Repo = Model.extend
duration
).property('_lastBuildDuration', 'lastBuildStartedAt', 'lastBuildFinishedAt')
sortOrder: (->
sortOrderForLandingPage: (->
state = @get('lastBuildState')
if state != 'passed' && state != 'failed'
0
@ -115,6 +115,14 @@ Repo = Model.extend
parseInt(@get('lastBuildId'))
).property('lastBuildId', 'lastBuildState')
sortOrder: (->
# cuz sortAscending seems buggy when set to false
if lastBuildFinishedAt = @get('lastBuildFinishedAt')
- new Date(lastBuildFinishedAt).getTime()
else
- new Date('9999').getTime() - parseInt(@get('lastBuildId'))
).property('lastBuildFinishedAt', 'lastBuildId')
stats: (->
if @get('slug')
@get('_stats') || $.get("https://api.github.com/repos/#{@get('slug')}", (data) =>

View File

@ -16,7 +16,7 @@ Route = BasicRoute.extend
withExternal: Ember.computed.union('repos', 'external')
sorted: Ember.computed.sort('withExternal', 'sortedReposKeys')
content: limit('sorted', 'limit')
sortedReposKeys: ['sortOrder:desc']
sortedReposKeys: ['sortOrderForLandingPage:desc']
limit: 3
).create()