zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

commit 2160241046fa000b7c7135561a3ee4198c9b4e85
parent b2620731f0a5b260da0eac7947068fb99dd7738f
Author: srfsh <dev@srf.sh>
Date:   Tue, 18 Oct 2022 20:48:01 +0300

Zenflows.VF.Proposal.{Type,Filter}: introduce id filters

Requested by Ennio.

Diffstat:
Msrc/zenflows/vf/proposal/filter.ex | 16++++++++++++++++
Msrc/zenflows/vf/proposal/type.ex | 2++
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