Skip to content

Commit

Permalink
Fix orders for search
Browse files Browse the repository at this point in the history
  • Loading branch information
beque committed Mar 2, 2023
1 parent 41ca0aa commit b727272
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/api/chemotion/search_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def sample_structure_search(c_id = @c_id, not_permitted = @dl_s && @dl_s < 1)
else
Sample.by_collection_id(c_id).search_by_fingerprint_sub(molfile)
end
scope = order_by_molecule(scope)
order_by_molecule(scope)
end

def order_by_molecule(scope)
Expand Down Expand Up @@ -150,7 +150,7 @@ def advanced_search(c_id = @c_id, dl = @dl)

scope = Sample.by_collection_id(c_id.to_i)
.where([query] + cond_val)
scope = order_by_molecule(scope)
order_by_molecule(scope)
end

# rubocop:disable Lint/SymbolConversion, Style/CaseLikeIf, Style/NumericPredicate, Style/ZeroLengthPredicate, Style/HashEachMethods
Expand Down Expand Up @@ -225,11 +225,11 @@ def search_by_ids_for_sample(c_id, model, ids)
.by_collection_id(c_id.to_i)
.where(id: ids)
scope = scope.product_only if list_filter_params.present? && list_filter_params[:product_only]
scope = search_order_by_molecule(scope) if params[:molecule_sort]
scope = order_by_updated_at(scope) if params[:molecule_sort]
scope
end

def search_order_by_molecule(scope)
def order_by_updated_at(scope)
scope.order('samples.updated_at ASC')
.page(params[:page]).per(page_size)
end
Expand Down

0 comments on commit b727272

Please sign in to comment.