Skip to content

Commit

Permalink
Update funding fee chart page
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-xiong committed Nov 10, 2023
1 parent eb80ec9 commit 68b04c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/controllers/page_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,18 @@ def funding_fee_chart
@to_date = Date.parse(params[:to_date]) rescue Date.today
@from_date = Date.parse(params[:from_date]) + 1.day rescue @to_date - 3.months

histories = FundingFeeHistory.includes(:snapshot_position).where('funding_fee_histories.user_id is null and funding_fee_histories.event_date >= ? and funding_fee_histories.event_date <= ?', @from_date, @to_date).order(event_date: :asc)
histories = FundingFeeHistory.where('funding_fee_histories.user_id is null and funding_fee_histories.event_date >= ? and funding_fee_histories.event_date <= ?', @from_date, @to_date).order(event_date: :asc)
histories = histories.where(origin_symbol: @symbol) if @symbol.present?
histories = histories.where(source: @source) if @source.present?
@data_summary = histories.data_summary
@data = {}
total_amount = FundingFeeHistory.where('user_id is null and event_date < ?', @from_date).sum(&:amount)
snapshots = SnapshotPosition.joins(:snapshot_info).where(snapshot_info: {user_id: nil}).available
histories.group_by(&:event_date).each do |date, value|
amount = value.sum(&:amount)
total_amount += amount
@data[date] = { amount: amount, revenue: value.sum(&:revenue), total_amount: total_amount, date: date }
revenue = snapshots.select{|x| x.event_date == date}.sum(&:revenue)
@data[date] = { amount: amount, revenue: revenue, total_amount: total_amount, date: date }
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@
个人仓位管理
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuTradingHistory">
<li class="nav-item">
<!-- <li class="nav-item">
<%= link_to "上传仓位列表", user_positions_path, class: "nav-link #{@page_index == 3 ? 'active' : ''}" %>
</li>
<li class="nav-item">
<%= link_to "上传仓位快照", snapshot_infos_path(user_id: current_user.id), class: "nav-link #{@page_index == 4 ? 'active' : ''}" %>
</li>
</li> -->
<li class="nav-item">
<%= link_to "合约仓位列表", user_synced_positions_path, class: "nav-link #{@page_index == 7 ? 'active' : ''}" %>
</li>
Expand Down

0 comments on commit 68b04c6

Please sign in to comment.