#237: update sorting of repositories
This commit is contained in:
parent
7555e0040b
commit
cf4bb18119
|
@ -1,6 +1,6 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class Repository < ActiveRecord::Base
|
||||
SORT = {'base' => 1, 'main' => 2, 'contrib' => 3, 'restricted' => 4, 'non-free' => 5}
|
||||
SORT = {'base' => 1, 'main' => 2, 'contrib' => 3, 'non-free' => 4, 'restricted' => 5}
|
||||
|
||||
belongs_to :platform
|
||||
|
||||
|
@ -66,8 +66,8 @@ class Repository < ActiveRecord::Base
|
|||
end
|
||||
later :destroy, :queue => :clone_build
|
||||
|
||||
def self.custom_sort repos
|
||||
repos.sort {|a,b| (Repository::SORT[a.name] || 100) <=> (Repository::SORT[b.name] || 100)}
|
||||
def self.custom_sort(repos)
|
||||
repos.select{ |r| SORT.keys.include?(r.name) }.sort{ |a,b| SORT[a.name] <=> SORT[b.name] } | repos.sort_by(&:name)
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
Loading…
Reference in New Issue