Sha256: f4dd3d6567f09102a45eb8d341fc585c381c2a8d12e5766b92e7113c9181724b
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require 'praxis/extensions/attribute_filtering/filtering_params' require 'praxis/extensions/attribute_filtering/query_builder' # To include in a controller module Praxis module Extensions module AttributeFiltering extend ActiveSupport::Concern def build_query(base_query) # rubocop:disable Metrics/AbcSize domain_model = self.media_type&.domain_model raise "No domain model defined for #{self.name}. Cannot use the attribute filtering helpers without it" unless domain_model filters = request.params.filters if request.params&.respond_to?(:filters) base_query = domain_model.craft_query( base_query , filters ) # TODO: add the field selector...and the pagination...and the ordering... resolved = Praxis::MediaType::FieldResolver.resolve(self.media_type, self.expanded_fields) base_query = FieldSelection::ActiveRecordQuerySelector.new(ds: base_query, model: domain_model.model, selectors: identity_map.selectors, resolved: resolved).generate # TODO: handle pagination and ordering base_query end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
praxis-0.22.pre.2 | lib/praxis/extensions/attribute_filtering.rb |
praxis-0.22.pre.1 | lib/praxis/extensions/attribute_filtering.rb |