From d6455d0fce5a8dd703b43f6204ceee3099025bdf Mon Sep 17 00:00:00 2001 From: Pan Xiong Date: Fri, 6 Oct 2023 21:45:45 +1100 Subject: [PATCH] split ranking snapshot page https://github.com/brtr/coin_elite/issues/729 --- .../ranking_snapshots_controller.rb | 14 +-- .../long_selling_tools.html.erb | 116 ++++++++++++++++++ .../short_selling_tools.html.erb | 116 ------------------ 3 files changed, 123 insertions(+), 123 deletions(-) diff --git a/app/controllers/ranking_snapshots_controller.rb b/app/controllers/ranking_snapshots_controller.rb index 13cd14b..9f0bd2c 100644 --- a/app/controllers/ranking_snapshots_controller.rb +++ b/app/controllers/ranking_snapshots_controller.rb @@ -19,12 +19,6 @@ def short_selling_tools @bottom_select = $redis.get('bottom_select_ranking').to_i @daily_ranking = @daily_ranking.select{|d| d['source'] == @source} if @source.present? @symbols = @daily_ranking.map{|r| [r["symbol"], r["source"]] } - @three_days_duration = $redis.get('three_days_duration') || 12 - @three_days_select = $redis.get('three_days_select').to_i - @three_days_ranking = JSON.parse($redis.get("get_three_days_tickers_#{@three_days_duration}_#{@three_days_select}")) rescue [] - @weekly_duration = $redis.get('weekly_duration') || 12 - @weekly_select = $redis.get('weekly_select').to_i - @weekly_ranking = JSON.parse($redis.get("get_one_week_tickers_#{@weekly_duration}_#{@weekly_select}")) rescue [] end def long_selling_tools @@ -33,6 +27,12 @@ def long_selling_tools @top_select = $redis.get('top_select_ranking').to_i @duration = $redis.get('top_select_duration').presence || 12 @top_select_ranking = JSON.parse($redis.get("get_top_24hr_tickers")) rescue daily_ranking + @three_days_duration = $redis.get('three_days_duration') || 12 + @three_days_select = $redis.get('three_days_select').to_i + @three_days_ranking = JSON.parse($redis.get("get_three_days_tickers_#{@three_days_duration}_#{@three_days_select}")) rescue [] + @weekly_duration = $redis.get('weekly_duration') || 12 + @weekly_select = $redis.get('weekly_select').to_i + @weekly_ranking = JSON.parse($redis.get("get_one_week_tickers_#{@weekly_duration}_#{@weekly_select}")) rescue [] end def refresh_tickers @@ -41,7 +41,7 @@ def refresh_tickers rank = params[:three_days_select] || params[:weekly_select] RefreshRankingSnapshotsJob.perform_later(duration, rank, data_type) - redirect_to short_selling_tools_ranking_snapshots_path(anchor: get_anchor(data_type)), notice: "正在更新,请稍等刷新查看最新排名..." + redirect_to long_selling_tools_ranking_snapshots_path(anchor: get_anchor(data_type)), notice: "正在更新,请稍等刷新查看最新排名..." end def ranking_graph diff --git a/app/views/ranking_snapshots/long_selling_tools.html.erb b/app/views/ranking_snapshots/long_selling_tools.html.erb index 42b794d..07d3c11 100644 --- a/app/views/ranking_snapshots/long_selling_tools.html.erb +++ b/app/views/ranking_snapshots/long_selling_tools.html.erb @@ -33,6 +33,122 @@ +

最近3天币种涨跌排名列表

+
+ <%= form_tag refresh_tickers_ranking_snapshots_path, class: "position-relative", method: "GET" do %> +
+ <%= select_tag(:three_days_duration, options_for_select([["最近一年内", 12], ["最近两年内", 24]], @three_days_duration ),{ class: 'select2-dropdown' }) %> + + <%= select_tag(:three_days_select, options_for_select([["所有币种", 0], ["前100名以内",3], ["前100名以外",4], ["前200名以内",5], ["前200名以外",6]], @three_days_select),{ prompt: '请选择币种排名', class: 'select2-dropdown' }) %> + <%= hidden_field_tag :data_type, :three_days %> + +
+ <% end %> +
+
+
+ + + + + + + + + + + <% @three_days_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["topPriceRatio"].to_f]}.reverse.first(10).each do |d| %> + + + + + + + <% end %> + +
币种3天内涨幅距离顶部比例来源
<%= get_symbol_url d["symbol"], d["source"] %><%= d["priceChangePercent"] + " %" %><%= d["bottomPriceRatio"] + " %" %><%= d["source"] %>
+
+
+ + + + + + + + + + + <% @three_days_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["bottomPriceRatio"].to_f]}.first(10).each do |d| %> + + + + + + + <% end %> + +
币种3天内跌幅距离底部比例来源
<%= get_symbol_url d["symbol"], d["source"] %><%= d["priceChangePercent"] + " %" %><%= d["bottomPriceRatio"] + " %" %><%= d["source"] %>
+
+
+

最近一周币种涨跌排名列表

+
+ <%= form_tag refresh_tickers_ranking_snapshots_path, class: "position-relative", method: "GET" do %> +
+ <%= select_tag(:weekly_duration, options_for_select([["最近一年内", 12], ["最近两年内", 24]], @weekly_duration ),{ class: 'select2-dropdown' }) %> + + <%= select_tag(:weekly_select, options_for_select([["所有币种", 0], ["前100名以内",3], ["前100名以外",4], ["前200名以内",5], ["前200名以外",6]], @weekly_select),{ prompt: '请选择币种排名', class: 'select2-dropdown' }) %> + <%= hidden_field_tag :data_type, :weekly %> + +
+ <% end %> +
+
+
+ + + + + + + + + + + <% @weekly_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["topPriceRatio"].to_f]}.reverse.first(10).each do |d| %> + + + + + + + <% end %> + +
币种一周内涨幅距离顶部比例来源
<%= get_symbol_url d["symbol"], d["source"] %><%= d["priceChangePercent"] + " %" %><%= d["topPriceRatio"] + " %" %><%= d["source"] %>
+
+
+ + + + + + + + + + + <% @weekly_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["bottomPriceRatio"].to_f]}.first(10).each do |d| %> + + + + + + + <% end %> + +
币种一周内跌幅距离底部比例来源
<%= get_symbol_url d["symbol"], d["source"] %><%= d["priceChangePercent"] + " %" %><%= d["bottomPriceRatio"] + " %" %><%= d["source"] %>
+
+
diff --git a/app/views/ranking_snapshots/short_selling_tools.html.erb b/app/views/ranking_snapshots/short_selling_tools.html.erb index d9929f2..a98bd17 100644 --- a/app/views/ranking_snapshots/short_selling_tools.html.erb +++ b/app/views/ranking_snapshots/short_selling_tools.html.erb @@ -121,122 +121,6 @@
-

最近3天币种涨跌排名列表

-
- <%= form_tag refresh_tickers_ranking_snapshots_path, class: "position-relative", method: "GET" do %> -
- <%= select_tag(:three_days_duration, options_for_select([["最近一年内", 12], ["最近两年内", 24]], @three_days_duration ),{ class: 'select2-dropdown' }) %> - - <%= select_tag(:three_days_select, options_for_select([["所有币种", 0], ["前100名以内",3], ["前100名以外",4], ["前200名以内",5], ["前200名以外",6]], @three_days_select),{ prompt: '请选择币种排名', class: 'select2-dropdown' }) %> - <%= hidden_field_tag :data_type, :three_days %> - -
- <% end %> -
-
-
- - - - - - - - - - - <% @three_days_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["topPriceRatio"].to_f]}.reverse.first(10).each do |d| %> - - - - - - - <% end %> - -
币种3天内涨幅距离顶部比例来源
<%= get_symbol_url d["symbol"], d["source"] %><%= d["priceChangePercent"] + " %" %><%= d["bottomPriceRatio"] + " %" %><%= d["source"] %>
-
-
- - - - - - - - - - - <% @three_days_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["bottomPriceRatio"].to_f]}.first(10).each do |d| %> - - - - - - - <% end %> - -
币种3天内跌幅距离底部比例来源
<%= get_symbol_url d["symbol"], d["source"] %><%= d["priceChangePercent"] + " %" %><%= d["bottomPriceRatio"] + " %" %><%= d["source"] %>
-
-
-

最近一周币种涨跌排名列表

-
- <%= form_tag refresh_tickers_ranking_snapshots_path, class: "position-relative", method: "GET" do %> -
- <%= select_tag(:weekly_duration, options_for_select([["最近一年内", 12], ["最近两年内", 24]], @weekly_duration ),{ class: 'select2-dropdown' }) %> - - <%= select_tag(:weekly_select, options_for_select([["所有币种", 0], ["前100名以内",3], ["前100名以外",4], ["前200名以内",5], ["前200名以外",6]], @weekly_select),{ prompt: '请选择币种排名', class: 'select2-dropdown' }) %> - <%= hidden_field_tag :data_type, :weekly %> - -
- <% end %> -
-
-
- - - - - - - - - - - <% @weekly_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["topPriceRatio"].to_f]}.reverse.first(10).each do |d| %> - - - - - - - <% end %> - -
币种一周内涨幅距离顶部比例来源
<%= get_symbol_url d["symbol"], d["source"] %><%= d["priceChangePercent"] + " %" %><%= d["topPriceRatio"] + " %" %><%= d["source"] %>
-
-
- - - - - - - - - - - <% @weekly_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["bottomPriceRatio"].to_f]}.first(10).each do |d| %> - - - - - - - <% end %> - -
币种一周内跌幅距离底部比例来源
<%= get_symbol_url d["symbol"], d["source"] %><%= d["priceChangePercent"] + " %" %><%= d["bottomPriceRatio"] + " %" %><%= d["source"] %>
-
-