uses standard search to create proposal summaries
This commit is contained in:
@@ -42,7 +42,6 @@ class Proposal < ActiveRecord::Base
|
||||
scope :sort_by_relevance , -> { all }
|
||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)}
|
||||
scope :in_categories, -> { where("tags.id IN (?)", ActsAsTaggableOn::Tag.category_ids) }
|
||||
|
||||
def searchable_values
|
||||
{ title => 'A',
|
||||
@@ -71,12 +70,12 @@ class Proposal < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.for_summary
|
||||
last_week.
|
||||
sort_by_confidence_score.
|
||||
in_categories.
|
||||
joins(:tags).
|
||||
select('proposals.*, tags.name as tag_name').
|
||||
group_by(&:tag_name)
|
||||
summary = {}
|
||||
categories = ActsAsTaggableOn::Tag.category_names
|
||||
categories.each do |category|
|
||||
summary[category] = search(category).last_week.sort_by_confidence_score.limit(3)
|
||||
end
|
||||
summary
|
||||
end
|
||||
|
||||
def description
|
||||
|
||||
Reference in New Issue
Block a user