Skip to content

Commit

Permalink
refactor public position page
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-xiong committed Mar 22, 2024
1 parent 37db7df commit 49c988a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/page_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ def user_positions
sort_type = params[:sort_type].presence || "desc"
@symbol = params[:search]
histories = UserPosition.available.where(user_id: nil)
@total_summary = histories.total_summary
histories = histories.where(origin_symbol: @symbol) if @symbol.present?
histories = histories.where(level: params[:level]) if params[:level].present?
histories = histories.select{|h| h.amount < @max_amount} if @flag && @max_amount > 0
parts = histories.partition {|h| h.send("#{sort}").nil? || h.send("#{sort}") == 'N/A'}
@histories = parts.last.sort_by{|h| h.send("#{sort}")} + parts.first
@histories = @histories.reverse if sort_type == "desc"
@histories = Kaminari.paginate_array(@histories).page(params[:page]).per(15)
@total_summary = UserPosition.available.total_summary
compare_date = params[:compare_date].presence || Date.yesterday
snapshots = SnapshotPosition.joins(:snapshot_info).where(snapshot_info: {source_type: 'synced', user_id: nil, event_date: compare_date})
snapshots = SnapshotInfo.where(source_type: 'synced', user_id: nil, event_date: compare_date).first.snapshot_positions
@last_summary = snapshots.last_summary(data: @total_summary)
@snapshots = snapshots.to_a
flash[:alert] = "找不到相应的快照" if params[:compare_date].present? && @snapshots.blank?
Expand Down

0 comments on commit 49c988a

Please sign in to comment.