Skip to content

Commit

Permalink
split ranking snapshot page brtr/coin_elite#729
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-xiong committed Oct 6, 2023
1 parent 01d4579 commit d6455d0
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 123 deletions.
14 changes: 7 additions & 7 deletions app/controllers/ranking_snapshots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
116 changes: 116 additions & 0 deletions app/views/ranking_snapshots/long_selling_tools.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,122 @@
</table>
</div>
</div>
<h3 class="mt-5" id="three_days_select_table">最近3天币种涨跌排名列表</h3>
<div class="mt-3 col-4">
<%= form_tag refresh_tickers_ranking_snapshots_path, class: "position-relative", method: "GET" do %>
<div class="input-group mb-3 position-filter">
<%= select_tag(:three_days_duration, options_for_select([["最近一年内", 12], ["最近两年内", 24]], @three_days_duration ),{ class: 'select2-dropdown' }) %>
<span class='ms-3'></span>
<%= 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 %>
<button type="submit" class="btn btn-primary mx-3">确定</button>
</div>
<% end %>
</div>
<div class="row mt-3">
<div class="col-6">
<table class="table">
<thead>
<tr class="table-container-tr">
<th>币种</th>
<th>3天内涨幅</th>
<th>距离顶部比例</th>
<th>来源</th>
</tr>
</thead>
<tbody>
<% @three_days_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["topPriceRatio"].to_f]}.reverse.first(10).each do |d| %>
<tr>
<td><%= get_symbol_url d["symbol"], d["source"] %></td>
<td><%= d["priceChangePercent"] + " %" %></td>
<td><%= d["bottomPriceRatio"] + " %" %></td>
<td><%= d["source"] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="col-6">
<table class="table">
<thead>
<tr class="table-container-tr">
<th>币种</th>
<th>3天内跌幅</th>
<th>距离底部比例</th>
<th>来源</th>
</tr>
</thead>
<tbody>
<% @three_days_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["bottomPriceRatio"].to_f]}.first(10).each do |d| %>
<tr>
<td><%= get_symbol_url d["symbol"], d["source"] %></td>
<td><%= d["priceChangePercent"] + " %" %></td>
<td><%= d["bottomPriceRatio"] + " %" %></td>
<td><%= d["source"] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<h3 class="mt-5" id="weekly_select_table">最近一周币种涨跌排名列表</h3>
<div class="mt-3 col-4">
<%= form_tag refresh_tickers_ranking_snapshots_path, class: "position-relative", method: "GET" do %>
<div class="input-group mb-3 position-filter">
<%= select_tag(:weekly_duration, options_for_select([["最近一年内", 12], ["最近两年内", 24]], @weekly_duration ),{ class: 'select2-dropdown' }) %>
<span class='ms-3'></span>
<%= 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 %>
<button type="submit" class="btn btn-primary mx-3">确定</button>
</div>
<% end %>
</div>
<div class="row mt-3">
<div class="col-6">
<table class="table">
<thead>
<tr class="table-container-tr">
<th>币种</th>
<th>一周内涨幅</th>
<th>距离顶部比例</th>
<th>来源</th>
</tr>
</thead>
<tbody>
<% @weekly_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["topPriceRatio"].to_f]}.reverse.first(10).each do |d| %>
<tr>
<td><%= get_symbol_url d["symbol"], d["source"] %></td>
<td><%= d["priceChangePercent"] + " %" %></td>
<td><%= d["topPriceRatio"] + " %" %></td>
<td><%= d["source"] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="col-6">
<table class="table">
<thead>
<tr class="table-container-tr">
<th>币种</th>
<th>一周内跌幅</th>
<th>距离底部比例</th>
<th>来源</th>
</tr>
</thead>
<tbody>
<% @weekly_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["bottomPriceRatio"].to_f]}.first(10).each do |d| %>
<tr>
<td><%= get_symbol_url d["symbol"], d["source"] %></td>
<td><%= d["priceChangePercent"] + " %" %></td>
<td><%= d["bottomPriceRatio"] + " %" %></td>
<td><%= d["source"] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>

<div id="ranking-modal-block">
Expand Down
116 changes: 0 additions & 116 deletions app/views/ranking_snapshots/short_selling_tools.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -121,122 +121,6 @@
</table>
</div>
</div>
<h3 class="mt-5" id="three_days_select_table">最近3天币种涨跌排名列表</h3>
<div class="mt-3 col-4">
<%= form_tag refresh_tickers_ranking_snapshots_path, class: "position-relative", method: "GET" do %>
<div class="input-group mb-3 position-filter">
<%= select_tag(:three_days_duration, options_for_select([["最近一年内", 12], ["最近两年内", 24]], @three_days_duration ),{ class: 'select2-dropdown' }) %>
<span class='ms-3'></span>
<%= 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 %>
<button type="submit" class="btn btn-primary mx-3">确定</button>
</div>
<% end %>
</div>
<div class="row mt-3">
<div class="col-6">
<table class="table">
<thead>
<tr class="table-container-tr">
<th>币种</th>
<th>3天内涨幅</th>
<th>距离顶部比例</th>
<th>来源</th>
</tr>
</thead>
<tbody>
<% @three_days_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["topPriceRatio"].to_f]}.reverse.first(10).each do |d| %>
<tr>
<td><%= get_symbol_url d["symbol"], d["source"] %></td>
<td><%= d["priceChangePercent"] + " %" %></td>
<td><%= d["bottomPriceRatio"] + " %" %></td>
<td><%= d["source"] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="col-6">
<table class="table">
<thead>
<tr class="table-container-tr">
<th>币种</th>
<th>3天内跌幅</th>
<th>距离底部比例</th>
<th>来源</th>
</tr>
</thead>
<tbody>
<% @three_days_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["bottomPriceRatio"].to_f]}.first(10).each do |d| %>
<tr>
<td><%= get_symbol_url d["symbol"], d["source"] %></td>
<td><%= d["priceChangePercent"] + " %" %></td>
<td><%= d["bottomPriceRatio"] + " %" %></td>
<td><%= d["source"] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<h3 class="mt-5" id="weekly_select_table">最近一周币种涨跌排名列表</h3>
<div class="mt-3 col-4">
<%= form_tag refresh_tickers_ranking_snapshots_path, class: "position-relative", method: "GET" do %>
<div class="input-group mb-3 position-filter">
<%= select_tag(:weekly_duration, options_for_select([["最近一年内", 12], ["最近两年内", 24]], @weekly_duration ),{ class: 'select2-dropdown' }) %>
<span class='ms-3'></span>
<%= 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 %>
<button type="submit" class="btn btn-primary mx-3">确定</button>
</div>
<% end %>
</div>
<div class="row mt-3">
<div class="col-6">
<table class="table">
<thead>
<tr class="table-container-tr">
<th>币种</th>
<th>一周内涨幅</th>
<th>距离顶部比例</th>
<th>来源</th>
</tr>
</thead>
<tbody>
<% @weekly_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["topPriceRatio"].to_f]}.reverse.first(10).each do |d| %>
<tr>
<td><%= get_symbol_url d["symbol"], d["source"] %></td>
<td><%= d["priceChangePercent"] + " %" %></td>
<td><%= d["topPriceRatio"] + " %" %></td>
<td><%= d["source"] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="col-6">
<table class="table">
<thead>
<tr class="table-container-tr">
<th>币种</th>
<th>一周内跌幅</th>
<th>距离底部比例</th>
<th>来源</th>
</tr>
</thead>
<tbody>
<% @weekly_ranking.sort_by{|d| [d["priceChangePercent"].to_f, d["bottomPriceRatio"].to_f]}.first(10).each do |d| %>
<tr>
<td><%= get_symbol_url d["symbol"], d["source"] %></td>
<td><%= d["priceChangePercent"] + " %" %></td>
<td><%= d["bottomPriceRatio"] + " %" %></td>
<td><%= d["source"] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>

<div id="ranking-modal-block">
Expand Down

0 comments on commit d6455d0

Please sign in to comment.