Skip to content

Commit

Permalink
fixed invoice sorting and finished auctions sort
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Sep 15, 2023
1 parent 6bbb9be commit ba81737
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion app/controllers/histories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class HistoriesController < ApplicationController

def index
auctions = Auction.where('ends_at <= ?', Time.zone.now)
.order(ends_at: :desc, domain_name: :asc)
.search(params)

@pagy, @auctions = pagy(auctions, items: params[:per_page] ||= 20,
Expand Down
8 changes: 5 additions & 3 deletions app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,19 @@ def self.search(params = {})
status
number
due_date
billing_profile_id]) || 'id'
billing_profile_name]) || 'id'
sort_direction = params[:direction].presence_in(%w[asc desc]) || 'desc'

query = with_search_scope(params[:search_string]).with_statuses(params[:statuses_contains])

if params[:sort] == 'channel'
query.left_outer_joins(:payment_orders)
.select("invoices.*, REPLACE(payment_orders.type, 'PaymentOrders::', '') AS payment_order_channel")
.order(Arel.sql("payment_order_channel #{sort_direction}"))
.order(Arel.sql("payment_order_channel #{sort_direction} NULLS LAST"))
elsif params[:sort] == 'billing_profile_name'
query.left_outer_joins(:billing_profile).order("billing_profiles.name #{sort_direction} NULLS LAST")
else
query.order("#{sort_column} #{sort_direction}")
query.order("#{sort_column} #{sort_direction} NULLS LAST")
end
end

Expand Down
3 changes: 1 addition & 2 deletions app/views/admin/invoices/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
<tr>
<th scope="col">
<%= t('invoices.billing_profile') %>
<%#= order_buttons('invoices.billing_profile_id') %>
<%= sort_link_to "", "billing_profile_id" %>
<%= sort_link_to "", "billing_profile_name" %>
</th>
<th scope="col">
<%= t('invoices.due_date') %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/auctions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<div class="four wide column"></div>
<div class="four wide column"></div>
<div class="four wide column" style='text-align: right;'>
<%= link_to t('auctions.finished_auctions'), histories_path, style: 'margin-bottom: 20px; display: block; font-size: 18px; color: #03456f;' %>
<%= link_to t('auctions.finished_auctions'), "#{histories_path}?direction=desc&sort=domain_name", style: 'margin-bottom: 20px; display: block; font-size: 18px; color: #03456f;' %>
</div>
</div>
<div class="grid one column">
Expand Down
3 changes: 2 additions & 1 deletion app/views/histories/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
</th>
<th scope="col">
<%= t('auctions.winning_bid') %>
<%= sort_link_to "", "users_price" %>
</th>
<th scope="col">
<%= t('auctions.auction_type') %>
Expand All @@ -79,7 +80,7 @@
<td><%= auction.ends_at.to_formatted_s(:long) %></td>
<td><%= auction.currently_winning_offer&.price if auction.platform == 'english' %></td>
<td>
<%= t("auctions.#{auction.platform&.downcase.presence || 'blind'}") %>
<%= t("auctions.#{auction.platform&.downcase.presence || 'blind (lagacy)'}") %>
</td>
</tr>
<% end %>
Expand Down

0 comments on commit ba81737

Please sign in to comment.