Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the main_or_tag method altogether and remove an addional query… #1398

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def profile_params
end

def search_with_search_params
@profiles = matching_profiles.map(&:profile_card_details)
@profiles = matching_profiles
@pagy, @records = pagy_array(@profiles)
# search results aggregated according to certain attributes to display as filters
aggs = ProfileGrouper.new(params[:locale], @profiles.map { |profile| profile[:id] }).agg_hash
Expand Down
1 change: 0 additions & 1 deletion app/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Category < ApplicationRecord

def self.sorted_categories
Category.all.includes(:translations).order(:position)

end

def short_name
Expand Down
10 changes: 2 additions & 8 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def self.typeahead(term, region: nil)
:city,
:willing_to_travel,
:nonprofit,
:main_topic_or_first_topic,
:main_topic,
keyword_init: true
)

Expand All @@ -128,7 +128,7 @@ def profile_card_details
city: city,
willing_to_travel: willing_to_travel,
nonprofit: nonprofit,
main_topic_or_first_topic: main_topic_or_first_topic,
main_topic: main_topic,
)
end

Expand All @@ -150,12 +150,6 @@ def name_or_email
fullname.present? ? fullname : email
end

def main_topic_or_first_topic
return nil unless main_topic

main_topic
end

# Try building a slug based on the following fields in
# increasing order of specificity.
def slug_candidate
Expand Down
4 changes: 2 additions & 2 deletions app/views/profiles/_profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<% tooltip_empty = !profile.iso_languages.present? && profile.city.nil? && profile.willing_to_travel.nil? && profile.nonprofit.nil? %>
<% title = render partial: "profiles/profile_tooltip", locals: { profile: profile } %>
<div class="col-sm-6 col-md-6 col-lg-3 my-3 profile-box">
<%= profile_image_link(Profile.find(profile.id)) %>
<%= profile_image_link(profile) %>
<div class="bg--white caption">
<div class="profile-name">
<%= link_to profile.fullname, profile_path(profile.id) %>
</div>
<div class="profile-subtitle">
<p>
<%= profile.main_topic_or_first_topic.truncate(60) if profile.main_topic_or_first_topic %>
<%= profile.main_topic.truncate(60) if profile.main_topic %>
</p>
<div
class="profile-tooltip"
Expand Down
4 changes: 2 additions & 2 deletions app/views/profiles/_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
</p>
<% end %>
<!-- main topic -->
<% if @profile.main_topic_or_first_topic %>
<% if @profile.main_topic %>
<p class="">
<span class="font-weight-bold">
<%= t(:main_topic, scope: 'profiles.show') %>
</span>
<%= @profile.main_topic_or_first_topic %>
<%= @profile.main_topic %>
</p>
<% end %>
<!-- twitter -->
Expand Down
Loading