If there's no repos on landing page for 10s, fetch some
This commit is contained in:
parent
17a8edba50
commit
918b6e043e
|
@ -108,12 +108,12 @@ Repo = Model.extend
|
|||
).property('_lastBuildDuration', 'lastBuildStartedAt', 'lastBuildFinishedAt')
|
||||
|
||||
sortOrder: (->
|
||||
# cuz sortAscending seems buggy when set to false
|
||||
if lastBuildFinishedAt = @get('lastBuildFinishedAt')
|
||||
- new Date(lastBuildFinishedAt).getTime()
|
||||
state = @get('lastBuildState')
|
||||
if state != 'passed' && state != 'failed'
|
||||
0
|
||||
else
|
||||
- new Date('9999').getTime() - parseInt(@get('lastBuildId'))
|
||||
).property('lastBuildFinishedAt', 'lastBuildId')
|
||||
parseInt(@get('lastBuildId'))
|
||||
).property('lastBuildId', 'lastBuildState')
|
||||
|
||||
stats: (->
|
||||
if @get('slug')
|
||||
|
|
|
@ -12,9 +12,11 @@ Route = BasicRoute.extend
|
|||
if store.hasRecordForId('build', buildId)
|
||||
state = repo.get('lastBuild.state')
|
||||
state == 'passed' || state == 'failed'
|
||||
sorted: Ember.computed.sort('repos', 'sortedReposKeys')
|
||||
external: []
|
||||
withExternal: Ember.computed.union('repos', 'external')
|
||||
sorted: Ember.computed.sort('withExternal', 'sortedReposKeys')
|
||||
content: limit('sorted', 'limit')
|
||||
sortedReposKeys: ['sortOrder:asc']
|
||||
sortedReposKeys: ['sortOrder:desc']
|
||||
limit: 3
|
||||
).create()
|
||||
|
||||
|
@ -24,6 +26,12 @@ Route = BasicRoute.extend
|
|||
@set('letMoreReposThrough', true)
|
||||
, 5000
|
||||
|
||||
setTimeout =>
|
||||
unless repos.get('length')
|
||||
@store.find('repo').then (reposFromRequest) ->
|
||||
repos.get('external').pushObjects reposFromRequest.toArray().slice(0, 3)
|
||||
, 10000
|
||||
|
||||
@_super.apply this, arguments
|
||||
|
||||
activate: ->
|
||||
|
@ -42,7 +50,9 @@ Route = BasicRoute.extend
|
|||
if @get('repos.length') < 3
|
||||
return true
|
||||
|
||||
if event == 'build:finished' && @get('letMoreReposThrough')
|
||||
if event == 'build:finished' &&
|
||||
['passed', 'failed'].indexOf(data.build.state) != -1 &&
|
||||
@get('letMoreReposThrough')
|
||||
@set('letMoreReposThrough', false)
|
||||
return true
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user