Sha256: 0f03309b26004f74447459588bfcb4bc404356d87ffd25352d9e59cca34fb6dd
Contents?: true
Size: 1.04 KB
Versions: 34
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require "active_support/concern" module Decidim module Initiatives # Common logic to ordering resources module Orderable extend ActiveSupport::Concern included do include Decidim::Orderable # Available orders based on enabled settings def available_orders @available_orders ||= begin available_orders = %w(random recent most_voted most_commented recently_published) available_orders end end def default_order "random" end def reorder(initiatives) case order when "most_voted" initiatives.order_by_supports when "most_commented" initiatives.order_by_most_commented when "recent" initiatives.order_by_most_recent when "recently_published" initiatives.order_by_most_recently_published else initiatives.order_randomly(random_seed) end end end end end end
Version data entries
34 entries across 34 versions & 1 rubygems