diff --git a/app/models/attachment.rb b/app/models/attachment.rb index c94a96def..d9eed6034 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -57,7 +57,8 @@ class Attachment < ApplicationRecord "ON #{Version.table_name}.project_id = #{Project.table_name}.id " \ "OR ( #{Attachment.table_name}.container_type='Project' " \ "AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )" - ) + ). + preload(:author, :container) end ) acts_as_activity_provider( @@ -73,7 +74,8 @@ class Attachment < ApplicationRecord "AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " \ "LEFT JOIN #{Project.table_name} " \ "ON #{Document.table_name}.project_id = #{Project.table_name}.id" - ) + ). + preload(:author, :container) end ) diff --git a/app/models/document.rb b/app/models/document.rb index f573f5827..5e9d24156 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -30,15 +30,14 @@ class Document < ApplicationRecord :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"}, :author => Proc.new do |o| - o.attachments.reorder("#{Attachment.table_name}.created_on ASC"). - first.try(:author) + o.attachments.min_by(&:created_on).try(:author) end, :url => Proc.new do |o| {:controller => 'documents', :action => 'show', :id => o.id} end ) - acts_as_activity_provider :scope => proc {preload(:project)} + acts_as_activity_provider :scope => proc {preload(:project, attachments: :author)} validates_presence_of :project, :title, :category validates_length_of :title, :maximum => 255 diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 3b68d2e3b..4c997d81e 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -45,7 +45,7 @@ class TimeEntry < ApplicationRecord ) acts_as_activity_provider :timestamp => "#{table_name}.created_on", :author_key => :user_id, - :scope => proc {joins(:project).preload(:project)} + :scope => proc {joins(:project).preload(:project, issue: [:tracker, :status])} acts_as_webhookable validates_presence_of :author_id, :user_id, :activity_id, :project_id, :hours, :spent_on diff --git a/app/models/wiki_content_version.rb b/app/models/wiki_content_version.rb index 79941bf41..206653c9d 100644 --- a/app/models/wiki_content_version.rb +++ b/app/models/wiki_content_version.rb @@ -52,7 +52,8 @@ class WikiContentVersion < ApplicationRecord "#{table_name}.id"). joins("LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{table_name}.page_id " \ "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " \ - "LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id") + "LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id"). + preload(:author, page: {wiki: :project}) end ) after_destroy :page_update_after_destroy