From a5b664ede3adff9ede22a13a33da0fd1ce298ff0 Mon Sep 17 00:00:00 2001 From: Bohung Date: Thu, 30 Sep 2021 11:44:39 +0800 Subject: [PATCH] Fix sort bug. --- app/controllers/archives_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/archives_controller.rb b/app/controllers/archives_controller.rb index 3a6a971..0fae38c 100644 --- a/app/controllers/archives_controller.rb +++ b/app/controllers/archives_controller.rb @@ -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"] || "",