Fix workers sorting, it should be done based on SortableMixin
This commit is contained in:
parent
87bccccde8
commit
3ecbc8f139
|
@ -15,31 +15,12 @@ Travis.reopen
|
||||||
groups = {}
|
groups = {}
|
||||||
for worker in content.toArray()
|
for worker in content.toArray()
|
||||||
host = worker.get('host')
|
host = worker.get('host')
|
||||||
groups[host] = Em.ArrayProxy.create(content: []) unless groups[host]
|
unless groups[host]
|
||||||
groups[host].pushObject(worker)
|
groups[host] = Em.ArrayProxy.create(Em.SortableMixin,
|
||||||
|
content: [],
|
||||||
prepareForSort = (str) ->
|
sortProperties: ['nameForSort']
|
||||||
match = str.match /(.*?)-(\d+)/
|
)
|
||||||
name = match[1]
|
groups[host].addObject(worker)
|
||||||
id = match[2].toString()
|
|
||||||
if id.length < 2
|
|
||||||
id = "00#{id}"
|
|
||||||
else if id.length < 3
|
|
||||||
id = "0#{id}"
|
|
||||||
|
|
||||||
"#{name}-#{id}"
|
|
||||||
|
|
||||||
for own host, workers of groups
|
|
||||||
groups[host] = workers.toArray().sort (a, b) ->
|
|
||||||
a = prepareForSort a.get('name')
|
|
||||||
b = prepareForSort b.get('name')
|
|
||||||
|
|
||||||
if a < b
|
|
||||||
-1
|
|
||||||
else if b < a
|
|
||||||
1
|
|
||||||
else
|
|
||||||
0
|
|
||||||
|
|
||||||
$.values(groups)
|
$.values(groups)
|
||||||
).property('length')
|
).property('length')
|
||||||
|
|
|
@ -29,3 +29,17 @@ require 'travis/model'
|
||||||
job: (->
|
job: (->
|
||||||
Travis.Job.find @get('job_id')
|
Travis.Job.find @get('job_id')
|
||||||
).property('job_id')
|
).property('job_id')
|
||||||
|
|
||||||
|
nameForSort: (->
|
||||||
|
if name = @get('name')
|
||||||
|
match = name.match /(.*?)-(\d+)/
|
||||||
|
if match
|
||||||
|
name = match[1]
|
||||||
|
id = match[2].toString()
|
||||||
|
if id.length < 2
|
||||||
|
id = "00#{id}"
|
||||||
|
else if id.length < 3
|
||||||
|
id = "0#{id}"
|
||||||
|
|
||||||
|
"#{name}-#{id}"
|
||||||
|
).property('name')
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user