Skip to content

Commit

Permalink
修复了两个 bug:
Browse files Browse the repository at this point in the history
1. 如果之前已经排序,就不要再用 id 排序了.
2. 使用范围过滤之后,自动排序仅当从来没有手动排序过才做.
  • Loading branch information
zw963 committed Jun 24, 2024
1 parent 43021a3 commit 7659374
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/actions/universities/index.cr
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ class Universities::Index < BrowserAction

query = order_by_action(query)

pages, universities = paginate(query.id.desc_order.distinct, per_page: 50)
query = query.id.desc_order unless query.query.ordered?

pages, universities = paginate(query.distinct, per_page: 50)

all_name_inputs = [
"q", "is_985", "is_211", "is_good", "is_exists_remark", "is_marked",
Expand Down Expand Up @@ -159,7 +161,7 @@ class Universities::Index < BrowserAction
if filter_by_column.presence
params.from_query["range_min_value"] = min_value.to_s
params.from_query["range_max_value"] = max_value.to_s
params.from_query["order_by"] = "#{filter_by_column}_min" if click_on.blank?
params.from_query["order_by"] = "#{filter_by_column}_min" if click_on.blank? && order_by.blank?

case filter_by_column
when "ranking_2023"
Expand Down

0 comments on commit 7659374

Please sign in to comment.