Skip to content

Commit

Permalink
Merge pull request #22 from performant-software/feature/udf21_table_f…
Browse files Browse the repository at this point in the history
…ilter

UDF #21 - Table filter
  • Loading branch information
dleadbetter authored Oct 6, 2022
2 parents 0cfd2bf + 76b5f8b commit 8e3a6ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def apply_filters(query)

query = filter_defineable(query)

query = filter_table(query)

query
end

Expand All @@ -19,5 +21,11 @@ def filter_defineable(query)

query.where(defineable_id: params[:defineable_id], defineable_type: params[:defineable_type])
end

def filter_table(query)
return query unless params[:table_name].present?

query.where(table_name: params[:table_name])
end
end
end
5 changes: 3 additions & 2 deletions app/models/concerns/user_defined_fields/fieldable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ def where_fieldable(name, value)
private

def validate_user_defined_fields
defineable = self.class.resolve_defineable&.call(self)
query = UserDefinedField
.where(table_name: self.class.to_s)

query = UserDefinedField.all
defineable = self.class.resolve_defineable&.call(self)

if defineable
query = query.where(
Expand Down

0 comments on commit 8e3a6ef

Please sign in to comment.