Skip to content

Commit

Permalink
当 filter 的时候,自动默认排序.
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed May 22, 2024
1 parent 11b2e1e commit bdc1821
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/actions/universities/index.cr
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,28 @@ class Universities::Index < BrowserAction

case filter_by_column
when "ranking_2023"
cookies.set("order_by", "ranking_2023_min_desc_order")
query = query.ranking_2023_min.gte(min_value).ranking_2023_min.lte(max_value) if !min_value.nil? && !max_value.nil?
when "ranking_2022"
cookies.set("order_by", "ranking_2022_min_desc_order")
query = query.ranking_2022_min.gte(min_value).ranking_2022_min.lte(max_value) if !min_value.nil? && !max_value.nil?
when "ranking_2021"
cookies.set("order_by", "ranking_2021_min_desc_order")
query = query.ranking_2021_min.gte(min_value).ranking_2021_min.lte(max_value) if !min_value.nil? && !max_value.nil?
when "ranking_2020"
cookies.set("order_by", "ranking_2020_min_desc_order")
query = query.ranking_2020_min.gte(min_value).ranking_2020_min.lte(max_value) if !min_value.nil? && !max_value.nil?
when "score_2023"
cookies.set("order_by", "score_2023_min_asc_order")
query = query.score_2023_min.gte(min_value).score_2023_min.lte(max_value) if !min_value.nil? && !max_value.nil?
when "score_2022"
cookies.set("order_by", "score_2022_min_asc_order")
query = query.score_2022_min.gte(min_value).score_2022_min.lte(max_value) if !min_value.nil? && !max_value.nil?
when "score_2021"
cookies.set("order_by", "score_2021_min_asc_order")
query = query.score_2021_min.gte(min_value).score_2021_min.lte(max_value) if !min_value.nil? && !max_value.nil?
when "score_2020"
cookies.set("order_by", "score_2020_min_asc_order")
query = query.score_2020_min.gte(min_value).score_2020_min.lte(max_value) if !min_value.nil? && !max_value.nil?
end
end
Expand Down

0 comments on commit bdc1821

Please sign in to comment.