From ba817370dc4b1d99829a191af6039bbe5535f580 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 15 Sep 2023 10:34:19 +0300 Subject: [PATCH] fixed invoice sorting and finished auctions sort --- app/controllers/histories_controller.rb | 1 - app/models/invoice.rb | 8 +++++--- app/views/admin/invoices/index.html.erb | 3 +-- app/views/auctions/index.html.erb | 2 +- app/views/histories/index.html.erb | 3 ++- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/histories_controller.rb b/app/controllers/histories_controller.rb index c77b6ed5e..02ee12d37 100644 --- a/app/controllers/histories_controller.rb +++ b/app/controllers/histories_controller.rb @@ -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, diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 188a396bb..30f263b53 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -70,7 +70,7 @@ 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]) @@ -78,9 +78,11 @@ def self.search(params = {}) 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 diff --git a/app/views/admin/invoices/index.html.erb b/app/views/admin/invoices/index.html.erb index 02752c7dc..787bbd924 100644 --- a/app/views/admin/invoices/index.html.erb +++ b/app/views/admin/invoices/index.html.erb @@ -40,8 +40,7 @@ <%= t('invoices.billing_profile') %> - <%#= order_buttons('invoices.billing_profile_id') %> - <%= sort_link_to "", "billing_profile_id" %> + <%= sort_link_to "", "billing_profile_name" %> <%= t('invoices.due_date') %> diff --git a/app/views/auctions/index.html.erb b/app/views/auctions/index.html.erb index 1986a7757..30c77968f 100644 --- a/app/views/auctions/index.html.erb +++ b/app/views/auctions/index.html.erb @@ -75,7 +75,7 @@
- <%= 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;' %>
diff --git a/app/views/histories/index.html.erb b/app/views/histories/index.html.erb index 3324bbaf9..b12303370 100644 --- a/app/views/histories/index.html.erb +++ b/app/views/histories/index.html.erb @@ -63,6 +63,7 @@ <%= t('auctions.winning_bid') %> + <%= sort_link_to "", "users_price" %> <%= t('auctions.auction_type') %> @@ -79,7 +80,7 @@ <%= auction.ends_at.to_formatted_s(:long) %> <%= auction.currently_winning_offer&.price if auction.platform == 'english' %> - <%= t("auctions.#{auction.platform&.downcase.presence || 'blind'}") %> + <%= t("auctions.#{auction.platform&.downcase.presence || 'blind (lagacy)'}") %> <% end %>