Skip to content

Commit

Permalink
Merge branch 'chore/homepage_optimization' into pwa-staging
Browse files Browse the repository at this point in the history
* chore/homepage_optimization:
  Include author in upcoming_meetings query
  Use eager loading for attachments on queries used in homepage
  • Loading branch information
entantoencuanto committed Apr 5, 2022
2 parents 6d6adcf + 66749a4 commit 558edfa
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def highlighted_assemblies
@highlighted_assemblies ||= OrganizationPrioritizedAssemblies
.new(current_organization, current_user)
.query
.with_attached_hero_image
.includes([:organization])
.limit(max_results)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def query
Decidim::Query.merge(
OrganizationPublishedConferences.new(@organization, @user),
PrioritizedConferences.new
).query
).query.with_attached_hero_image
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions decidim-core/lib/decidim/has_attachments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def photo
#
# Returns an Array<Attachment>
def photos
@photos ||= attachments.order(:weight).select(&:photo?)
@photos ||= attachments.with_attached_file.order(:weight).select(&:photo?)
end

# All the attachments that are documents for this model.
#
# Returns an Array<Attachment>
def documents
@documents ||= attachments.order(:weight).includes(:attachment_collection).select(&:document?)
@documents ||= attachments.with_attached_file.order(:weight).includes(:attachment_collection).select(&:document?)
end

# All the attachments that are documents for this model that has a collection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def show

def upcoming_meetings
@upcoming_meetings ||= Decidim::Meetings::Meeting
.includes(component: :participatory_space)
.includes(:author, component: :participatory_space)
.where(component: meeting_components)
.visible_for(current_user)
.published
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def highlighted_processes
OrganizationPublishedParticipatoryProcesses.new(current_organization, current_user) |
HighlightedParticipatoryProcesses.new |
FilteredParticipatoryProcesses.new("active")
).query.includes([:organization]).limit(highlighted_processes_max_results)
).query.with_attached_hero_image.includes([:organization, :hero_image_attachment]).limit(highlighted_processes_max_results)
end
end

Expand Down

0 comments on commit 558edfa

Please sign in to comment.