displays only proposals from last week ordered by votes
This commit is contained in:
@@ -36,7 +36,7 @@ class ProposalsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def summary
|
def summary
|
||||||
@proposals = Proposal.grouped_by_categories(Proposal.category_names)
|
@proposals = Proposal.last_week.sort_by_confidence_score.grouped_by_categories(Proposal.category_names)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class Proposal < ActiveRecord::Base
|
|||||||
scope :sort_by_random, -> { reorder("RANDOM()") }
|
scope :sort_by_random, -> { reorder("RANDOM()") }
|
||||||
scope :sort_by_relevance , -> { all }
|
scope :sort_by_relevance , -> { all }
|
||||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||||
scope :last_week, -> { where("created_at >= ?", 7.days.ago)}
|
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)}
|
||||||
|
|
||||||
scope :grouped_by_categories, -> (categories) { where("lower(tags.name) IN (?)", categories).
|
scope :grouped_by_categories, -> (categories) { where("lower(tags.name) IN (?)", categories).
|
||||||
joins(:tags).select('proposals.*, tags.name').
|
joins(:tags).select('proposals.*, tags.name').
|
||||||
|
|||||||
Reference in New Issue
Block a user