commit f22e1cc6fd4cac47cc0a6033969a9895751148f5
parent b2620731f0a5b260da0eac7947068fb99dd7738f
Author: sir fish <dev@srf.sh>
Date: Tue, 18 Oct 2022 17:51:04 +0000
Merge pull request #26 from dyne/srfsh/filter
Add more filters
Diffstat:
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/zenflows/vf/proposal/filter.ex b/src/zenflows/vf/proposal/filter.ex
@@ -79,6 +79,16 @@ defp f(q, {:or_primary_intents_resource_inventoried_as_name, v}) do
|> join(:primary_intents_resource_inventoried_as)
|> or_where([primary_intents_resource_inventoried_as: r], ilike(r.name, ^"%#{Filter.escape_like(v)}%"))
end
+defp f(q, {:primary_intents_resource_inventoried_as_id, v}) do
+ q
+ |> join(:primary_intents_resource_inventoried_as)
+ |> where([primary_intents_resource_inventoried_as: r], r.id in ^v)
+end
+defp f(q, {:or_primary_intents_resource_inventoried_as_id, v}) do
+ q
+ |> join(:primary_intents_resource_inventoried_as)
+ |> or_where([primary_intents_resource_inventoried_as: r], r.id in ^v)
+end
# join primary_intents
defp join(q, :primary_intents) do
@@ -104,6 +114,8 @@ embedded_schema do
field :or_primary_intents_resource_inventoried_as_classified_as, {:array, :string}
field :primary_intents_resource_inventoried_as_name, :string
field :or_primary_intents_resource_inventoried_as_name, :string
+ field :primary_intents_resource_inventoried_as_id, {:array, ID}
+ field :or_primary_intents_resource_inventoried_as_id, {:array, ID}
end
@cast ~w[
@@ -115,6 +127,8 @@ end
or_primary_intents_resource_inventoried_as_classified_as
primary_intents_resource_inventoried_as_name
or_primary_intents_resource_inventoried_as_name
+ primary_intents_resource_inventoried_as_id
+ or_primary_intents_resource_inventoried_as_id
]a
@spec chgset(params()) :: Changeset.t()
@@ -137,5 +151,7 @@ defp chgset(params) do
:or_primary_intents_resource_inventoried_as_classified_as)
|> Filter.check_xor(:primary_intents_resource_inventoried_as_name,
:or_primary_intents_resource_inventoried_as_name)
+ |> Filter.check_xor(:primary_intents_resource_inventoried_as_id,
+ :or_primary_intents_resource_inventoried_as_id)
end
end
diff --git a/src/zenflows/vf/proposal/type.ex b/src/zenflows/vf/proposal/type.ex
@@ -139,6 +139,8 @@ input_object :proposal_filter_params do
field :or_primary_intents_resource_inventoried_as_classified_as, list_of(non_null(:uri))
field :primary_intents_resource_inventoried_as_name, :string
field :or_primary_intents_resource_inventoried_as_name, :string
+ field :primary_intents_resource_inventoried_as_id, list_of(non_null(:id))
+ field :or_primary_intents_resource_inventoried_as_id, list_of(non_null(:id))
end
object :query_proposal do