Sha256: c6911448280374e2f523cd70645800538bd3217e6004c2b623cc6b326cc46997
Contents?: true
Size: 1.07 KB
Versions: 14
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Decidim module Budgets # This class handles search and filtering of projects. Needs a # `current_component` param with a `Decidim::Component` in order to # find the projects. class ProjectSearch < ResourceSearch text_search_fields :title, :description # Public: Initializes the service. # component - A Decidim::Component to get the projects from. def initialize(options = {}) super(Project.all, options) end # Creates the SearchLight base query. def base_query raise "Missing budget" unless budget raise "Missing component" unless component @scope.where(budget: budget) end # Returns the random projects for the current page. def results Project.where(id: super.pluck(:id)).includes([:scope, :component, :attachments, :category]) end private # Private: Since budget is not used by a search method we need # to define the method manually. def budget options[:budget] end end end end
Version data entries
14 entries across 14 versions & 1 rubygems