Skip to content

Commit

Permalink
add source filter to synced transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-xiong committed Sep 18, 2023
1 parent 07e6a2c commit d3d9217
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/controllers/synced_transactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ def index
sort = params[:sort].presence || "event_time"
sort_type = params[:sort_type].presence || "desc"
@symbol = params[:search]
@source = params[:tx_source]
txs = SyncedTransaction.where(user_id: nil)
@total_symbols = txs.pluck(:origin_symbol).uniq
txs = txs.where(origin_symbol: @symbol) if @symbol.present?
txs = txs.where(source: @source) if @source.present?
txs = txs.available if @flag
parts = txs.partition {|h| h.send("#{sort}").nil? || h.send("#{sort}") == 'N/A'}
@txs = parts.last.sort_by{|h| h.send("#{sort}")} + parts.first
Expand Down
7 changes: 5 additions & 2 deletions app/views/synced_transactions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
</button>
</h3>
<div class="mb-3">
<%= form_tag synced_transactions_path, id: "search_targets", class: "position-relative", method: "GET" do %>
<div class="input-group mb-3">
<%= form_tag synced_transactions_path, id: "search_targets", method: "GET" do %>
<div class="input-group mb-3 position-filter">
<%= select_tag(:search, options_for_select(@total_symbols, @symbol), { prompt: '请选择币种...', class: 'select2-dropdown form-control' }) %>
<span class='ms-3'></span>
<%= select_tag(:tx_source, options_for_select(['binance', 'okx'], @source),{ prompt: '请选择来源...', class: 'select2-dropdown form-control'}) %>
<span class='ms-3'></span>
<button type="submit" class="btn btn-primary mx-3">确定</button>
<%= link_to "Reset", synced_transactions_path, class: 'btn btn-warning' %>
</div>
Expand Down

0 comments on commit d3d9217

Please sign in to comment.