Fix sort bug.

This commit is contained in:
BoHung Chiu 2021-09-30 11:44:39 +08:00
parent 0c9b3786c4
commit a5b664ede3
1 changed files with 2 additions and 2 deletions

View File

@ -119,7 +119,7 @@ class ArchivesController < ApplicationController
archives = archive_files.where(:id.in=>taggings).to_a
serial_number = 0
if archives.count != 0
archives = archives.sort_by{|k| [(k["is_top"] ? 0 : 1) ,sort_order * (k["sort_number"].nil? ? Float::INFINITY : k["sort_number"].to_i),-k["created_at"].to_i]}.map.with_index do |archive,idx|
archives = archives.sort_by{|k| [(k["is_top"] ? 0 : 1) ,(k["sort_number"].nil? ? Float::INFINITY : sort_order * k["sort_number"].to_i),-k["created_at"].to_i]}.map.with_index do |archive,idx|
statuses = archive.statuses_with_classname.collect do |status|
{
"status" => status["name"] || "",
@ -182,7 +182,7 @@ class ArchivesController < ApplicationController
cats = categories_sort.collect do |category|
url_to_edit = OrbitHelper.user_has_cateogry?(category) ? "/admin/archive_files?filters[category][]=#{category.id.to_s}" : ""
serial_number = 0
archives = files_by_category[category].sort_by{|k| [(k["is_top"] ? 0 : 1) ,sort_order * (k["sort_number"].nil? ? Float::INFINITY : k["sort_number"].to_i),-k["created_at"].to_i]}.collect.with_index do |archive,idx|
archives = files_by_category[category].sort_by{|k| [(k["is_top"] ? 0 : 1) ,(k["sort_number"].nil? ? Float::INFINITY : sort_order * k["sort_number"].to_i),-k["created_at"].to_i]}.collect.with_index do |archive,idx|
statuses = archive.statuses_with_classname.collect do |status|
{
"status" => status["name"] || "",