Skip to content

Commit

Permalink
Address performance of #3799 by using activity summary table instead …
Browse files Browse the repository at this point in the history
…of deeds
  • Loading branch information
benwbrum committed Oct 24, 2023
1 parent e84bbc4 commit ff02c70
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def summary
# Collaborator Dashboard - watchlist
def watchlist
works = Work.joins(:deeds).where(deeds: { user_id: current_user.id }).distinct
collections = Collection.joins(:deeds).where(deeds: { user_id: current_user.id }).distinct.order_by_recent_activity.limit(5)
collections = Collection.where(id: current_user.ahoy_activity_summaries.pluck(:collection_id)).distinct.order_by_recent_activity.limit(5)
document_sets = DocumentSet.joins(works: :deeds).where(works: { id: works.ids }).order('deeds.created_at DESC').distinct.limit(5)
collections_list(true) # assigns @collections_and_document_sets for private collections only
@collections = (collections + document_sets).sort { |a, b| a.title <=> b.title }.take(5)
Expand Down
1 change: 1 addition & 0 deletions app/models/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Collection < ApplicationRecord
has_and_belongs_to_many :owners, :class_name => 'User', :join_table => :collection_owners
has_and_belongs_to_many :collaborators, :class_name => 'User', :join_table => :collection_collaborators
has_and_belongs_to_many :reviewers, :class_name => 'User', :join_table => :collection_reviewers
has_many :ahoy_activity_summaries

validates :title, presence: true, length: { minimum: 3, maximum: 255 }
validates :slug, format: { with: /[[:alpha:]]/ }
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class User < ApplicationRecord

has_many :collection_blocks, dependent: :destroy
has_many :blocked_collections, through: :collection_blocks, source: :collection
has_many :ahoy_activity_summaries

has_and_belongs_to_many(:scribe_works,
:join_table => 'transcribe_authorizations',
Expand Down

0 comments on commit ff02c70

Please sign in to comment.