Skip to content

Commit

Permalink
Fix distribution export, item columns in alphabetically order (#4617)
Browse files Browse the repository at this point in the history
  • Loading branch information
auliafaizahr committed Sep 2, 2024
1 parent 742bfc1 commit 5d854fe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/services/exports/export_distributions_csv_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def base_headers
def item_headers
return @item_headers if @item_headers

@item_headers = @organization.items.order(:created_at).distinct.select([:created_at, :name]).map(&:name)
@item_headers = @organization.items.select("DISTINCT ON (LOWER(name)) items.name").order("LOWER(name) ASC").map(&:name)
end

def build_row_data(distribution)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
let(:item_id) { duplicate_item.id }
let(:item_name) { duplicate_item.name }
let(:filters) { {by_item_id: item_id} }
let(:all_org_items) { Item.where(organization:).uniq.sort_by(&:created_at) }
let(:all_org_items) { Item.where(organization:).uniq.sort_by { |item| item.name.downcase } }

let(:total_item_quantities) do
template = all_org_items.pluck(:name).index_with(0)
Expand Down

0 comments on commit 5d854fe

Please sign in to comment.