Skip to content

Commit

Permalink
fix(offers index): current_user is actually a current_visitor_or_user
Browse files Browse the repository at this point in the history
  • Loading branch information
fitchMitch committed Jan 23, 2025
1 parent 706373c commit 9d9b6c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/controllers/internship_offers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ def alternative_internship_offers
priority_offers = Finders::InternshipOfferConsumer.new(
params: params.permit(*priority),
user: current_user_or_visitor
).all_with_grade(current_user).to_a
).all_with_grade(current_user_or_visitor).to_a

if priority_offers.count < 5 && priority == %i[latitude longitude radius]
priority_offers = Finders::InternshipOfferConsumer.new(
params: params.permit(*priority).merge(radius: Nearbyable::DEFAULT_NEARBY_RADIUS_IN_METER + 40_000),
user: current_user_or_visitor
).all_with_grade(current_user).to_a
).all_with_grade(current_user_or_visitor).to_a
end

alternative_offers << priority_offers
Expand All @@ -145,7 +145,7 @@ def alternative_internship_offers

if alternative_offers.count < 5
alternative_offers += InternshipOffer.uncompleted
.with_grade(current_user)
.with_grade(current_user_or_visitor)
.last(5 - alternative_offers.count)
alternative_offers = alternative_offers.uniq
end
Expand Down
2 changes: 1 addition & 1 deletion app/libs/finders/listable_internship_offer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def all_without_page
end

def all_with_grade(user)
if user.student? && user.grade.present?
if user.present? && user.student? && user.grade.present?
finder.base_query.with_grade(student.grade)
else
finder.base_query
Expand Down

0 comments on commit 9d9b6c1

Please sign in to comment.