Sha256: 83b109e3c486eacf59e6c3f91204f0123cb2b435cd838efa1cbb8a8980176334
Contents?: true
Size: 1.56 KB
Versions: 3
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true module Decidim module Sortitions module Admin class ParticipatorySpaceProposals < Rectify::Query # Sugar syntax. Retrieve all proposals for the given sortition. def self.for(sortition) new(sortition).query end # Initializes the class. # # sortition - a sortition to select proposals def initialize(sortition) @sortition = sortition @category = sortition.category @request_timestamp = sortition.request_timestamp end # Given a particpiatory process retrieves its proposals # # Returns an ActiveRecord::Relation. def query if category.nil? return Decidim::Proposals::Proposal .except_withdrawn .except_drafts .where("created_at < ?", request_timestamp) .where(component: sortition.decidim_proposals_component) .order(id: :asc) end # categorization -> category Decidim::Proposals::Proposal .joins(:categorization) .except_withdrawn .except_drafts .where(component: sortition.decidim_proposals_component) .where("decidim_proposals_proposals.created_at < ?", request_timestamp) .where("decidim_categorizations.decidim_category_id = ?", category.id) .order(id: :asc) end private attr_reader :sortition, :category, :request_timestamp end end end end
Version data entries
3 entries across 3 versions & 1 rubygems