Skip to content

Commit

Permalink
Make sure the order of facilities do not change
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJackson-Oslo committed Feb 29, 2024
1 parent 2eb28f3 commit a9ed0ec
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/models/space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ def non_relevant_space_facilities(grouped: false)
end

def filtered_space_facilities(relevant: true, grouped: false, user: nil)
ungrouped_facilities = space_facilities.includes(facility: [:facilities_categories]).where(relevant:)
# If a user is defined, include facility reviews for that user
if user.present?
ungrouped_facilities = ungrouped_facilities
.includes(facility: [:facilities_categories, :facility_reviews])
.where(relevant:)
end
ungrouped_facilities = space_facilities
.includes(
facility: [
:facility_reviews,
:facilities_categories
]
)
.where(relevant:)
.order("facilities.title")

return ungrouped_facilities unless grouped

Expand Down

0 comments on commit a9ed0ec

Please sign in to comment.