zf

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

commit aac8a34527647b19b9a5a77d14a1546cbf728b48
parent 2a10611ed353127c0155bffb72f9bec5a9a7d490
Author: srfsh <dev@srf.sh>
Date:   Sun, 14 Aug 2022 12:41:42 +0300

Zenflows.{VF,DB.Repo.Migrations},ZenflowsTest: add timestamps

They'll be useful when we implement paging.

Diffstat:
Mpriv/repo/migrations/20211110082423_fill_vf_unit.exs | 1+
Mpriv/repo/migrations/20211111090805_fill_vf_spatial_thing.exs | 1+
Mpriv/repo/migrations/20211111093203_fill_vf_process_specification.exs | 1+
Mpriv/repo/migrations/20211111094959_fill_vf_resource_specification.exs | 1+
Mpriv/repo/migrations/20211111102319_fill_vf_recipe_resource.exs | 1+
Mpriv/repo/migrations/20211111111357_fill_vf_recipe_process.exs | 1+
Mpriv/repo/migrations/20211111113613_fill_vf_recipe_exchange.exs | 1+
Mpriv/repo/migrations/20211111114050_fill_vf_recipe_flow.exs | 1+
Mpriv/repo/migrations/20211111175352_fill_vf_agent.exs | 1+
Mpriv/repo/migrations/20211111175446_fill_vf_agent_relationship.exs | 1+
Mpriv/repo/migrations/20211111175449_fill_vf_agent_relationship_role.exs | 1+
Mpriv/repo/migrations/20211111175525_fill_vf_role_behavior.exs | 1+
Mpriv/repo/migrations/20211111185643_fill_vf_agreement.exs | 2+-
Mpriv/repo/migrations/20211111191749_fill_vf_scenario_definition.exs | 1+
Mpriv/repo/migrations/20211111194625_fill_vf_scenario.exs | 1+
Mpriv/repo/migrations/20211112115624_fill_vf_plan.exs | 1+
Mpriv/repo/migrations/20211112185747_fill_vf_process.exs | 1+
Mpriv/repo/migrations/20211113064700_fill_vf_product_batch.exs | 1+
Mpriv/repo/migrations/20211113071804_fill_vf_economic_resource.exs | 1+
Mpriv/repo/migrations/20211114144908_fill_vf_economic_event.exs | 1+
Mpriv/repo/migrations/20211114165810_fill_vf_appreciation.exs | 1+
Mpriv/repo/migrations/20211114190636_fill_vf_intent.exs | 1+
Mpriv/repo/migrations/20211115055335_fill_vf_commitment.exs | 2+-
Mpriv/repo/migrations/20211115071129_fill_vf_fulfillment.exs | 1+
Mpriv/repo/migrations/20211115074158_fill_vf_event_or_commitment.exs | 1+
Mpriv/repo/migrations/20211115103758_fill_vf_satisfaction.exs | 1+
Mpriv/repo/migrations/20211115173048_fill_vf_claim.exs | 1+
Mpriv/repo/migrations/20211115181352_fill_vf_settlement.exs | 1+
Mpriv/repo/migrations/20211115183013_fill_vf_proposal.exs | 2+-
Mpriv/repo/migrations/20211115185611_fill_vf_proposed_intent.exs | 1+
Mpriv/repo/migrations/20211118061736_fill_vf_proposed_to.exs | 1+
Msrc/zenflows/vf/agent.ex | 1+
Msrc/zenflows/vf/agent_relationship.ex | 1+
Msrc/zenflows/vf/agent_relationship_role.ex | 1+
Msrc/zenflows/vf/agreement.ex | 5++---
Msrc/zenflows/vf/agreement/type.ex | 8+-------
Msrc/zenflows/vf/appreciation.ex | 1+
Msrc/zenflows/vf/claim.ex | 5++---
Msrc/zenflows/vf/commitment.ex | 3+--
Msrc/zenflows/vf/economic_event.ex | 1+
Msrc/zenflows/vf/economic_resource.ex | 1+
Msrc/zenflows/vf/event_or_commitment.ex | 1+
Msrc/zenflows/vf/fulfillment.ex | 1+
Msrc/zenflows/vf/intent.ex | 1+
Msrc/zenflows/vf/organization.ex | 1+
Msrc/zenflows/vf/person.ex | 1+
Msrc/zenflows/vf/plan.ex | 5++---
Msrc/zenflows/vf/plan/type.ex | 8+-------
Msrc/zenflows/vf/process.ex | 1+
Msrc/zenflows/vf/process_specification.ex | 1+
Msrc/zenflows/vf/product_batch.ex | 1+
Msrc/zenflows/vf/proposal.ex | 11++++++++---
Asrc/zenflows/vf/proposal/type.ex | 177+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/zenflows/vf/proposed_intent.ex | 1+
Asrc/zenflows/vf/proposed_intent/type.ex | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/zenflows/vf/proposed_to.ex | 1+
Msrc/zenflows/vf/recipe_exchange.ex | 1+
Msrc/zenflows/vf/recipe_flow.ex | 1+
Msrc/zenflows/vf/recipe_process.ex | 1+
Msrc/zenflows/vf/recipe_resource.ex | 1+
Msrc/zenflows/vf/resource_specification.ex | 1+
Msrc/zenflows/vf/role_behavior.ex | 1+
Msrc/zenflows/vf/satisfaction.ex | 1+
Msrc/zenflows/vf/scenario.ex | 1+
Msrc/zenflows/vf/scenario_definition.ex | 1+
Msrc/zenflows/vf/settlement.ex | 1+
Msrc/zenflows/vf/spatial_thing.ex | 1+
Msrc/zenflows/vf/unit.ex | 1+
Mtest/help/factory.ex | 3---
Mtest/vf/agreement/domain.test.exs | 4----
Mtest/vf/agreement/type.test.exs | 6------
Mtest/vf/claim.test.exs | 3---
Mtest/vf/commitment.test.exs | 7-------
Mtest/vf/plan/domain.test.exs | 4----
Mtest/vf/plan/type.test.exs | 5-----
75 files changed, 318 insertions(+), 63 deletions(-)

diff --git a/priv/repo/migrations/20211110082423_fill_vf_unit.exs b/priv/repo/migrations/20211110082423_fill_vf_unit.exs @@ -22,6 +22,7 @@ def change() do alter table("vf_unit") do add :label, :text, null: false add :symbol, :text, null: false + timestamps() end end end diff --git a/priv/repo/migrations/20211111090805_fill_vf_spatial_thing.exs b/priv/repo/migrations/20211111090805_fill_vf_spatial_thing.exs @@ -26,6 +26,7 @@ def change() do add :lat, :float add :long, :float add :alt, :float + timestamps() end end end diff --git a/priv/repo/migrations/20211111093203_fill_vf_process_specification.exs b/priv/repo/migrations/20211111093203_fill_vf_process_specification.exs @@ -22,6 +22,7 @@ def change() do alter table("vf_process_specification") do add :name, :text, null: false add :note, :text + timestamps() end end end diff --git a/priv/repo/migrations/20211111094959_fill_vf_resource_specification.exs b/priv/repo/migrations/20211111094959_fill_vf_resource_specification.exs @@ -26,6 +26,7 @@ def change() do add :resource_classified_as, {:array, :text} add :default_unit_of_resource_id, references("vf_unit") add :default_unit_of_effort_id, references("vf_unit") + timestamps() end end end diff --git a/priv/repo/migrations/20211111102319_fill_vf_recipe_resource.exs b/priv/repo/migrations/20211111102319_fill_vf_recipe_resource.exs @@ -28,6 +28,7 @@ def change() do add :resource_conforms_to_id, references("vf_resource_specification") add :unit_of_resource_id, references("vf_unit") add :unit_of_effort_id, references("vf_unit") + timestamps() end end end diff --git a/priv/repo/migrations/20211111111357_fill_vf_recipe_process.exs b/priv/repo/migrations/20211111111357_fill_vf_recipe_process.exs @@ -32,6 +32,7 @@ def change() do add :process_classified_as, {:array, :text} add :has_duration_unit_type, :vf_time_unit add :has_duration_numeric_duration, :float + timestamps() end create constraint("vf_recipe_process", :has_duration, check: @check) diff --git a/priv/repo/migrations/20211111113613_fill_vf_recipe_exchange.exs b/priv/repo/migrations/20211111113613_fill_vf_recipe_exchange.exs @@ -22,6 +22,7 @@ def change() do alter table("vf_recipe_exchange") do add :name, :text, null: false add :note, :text + timestamps() end end end diff --git a/priv/repo/migrations/20211111114050_fill_vf_recipe_flow.exs b/priv/repo/migrations/20211111114050_fill_vf_recipe_flow.exs @@ -46,6 +46,7 @@ def change() do add :resource_quantity_has_numerical_value, :float add :effort_quantity_has_unit_id, references("vf_unit") add :effort_quantity_has_numerical_value, :float + timestamps() end create constraint("vf_recipe_flow", :resource_quantity_check, check: @resqty_check) diff --git a/priv/repo/migrations/20211111175352_fill_vf_agent.exs b/priv/repo/migrations/20211111175352_fill_vf_agent.exs @@ -47,6 +47,7 @@ def change() do add :image, :text add :note, :text add :primary_location_id, references("vf_spatial_thing") + timestamps() # person add :user, :text diff --git a/priv/repo/migrations/20211111175446_fill_vf_agent_relationship.exs b/priv/repo/migrations/20211111175446_fill_vf_agent_relationship.exs @@ -25,6 +25,7 @@ def change() do add :object_id, references("vf_agent"), null: false add :relationship_id, references("vf_agent_relationship_role"), null: false # inscope_of + timestamps() end end end diff --git a/priv/repo/migrations/20211111175449_fill_vf_agent_relationship_role.exs b/priv/repo/migrations/20211111175449_fill_vf_agent_relationship_role.exs @@ -24,6 +24,7 @@ def change() do add :role_label, :text, null: false add :inverse_role_label, :text add :role_behavior_id, references("vf_role_behavior") + timestamps() end end end diff --git a/priv/repo/migrations/20211111175525_fill_vf_role_behavior.exs b/priv/repo/migrations/20211111175525_fill_vf_role_behavior.exs @@ -22,6 +22,7 @@ def change() do alter table("vf_role_behavior") do add :name, :text, null: false add :note, :text + timestamps() end end end diff --git a/priv/repo/migrations/20211111185643_fill_vf_agreement.exs b/priv/repo/migrations/20211111185643_fill_vf_agreement.exs @@ -22,7 +22,7 @@ def change() do alter table("vf_agreement") do add :name, :text, null: false add :note, :text - add :created, :timestamptz, null: false + timestamps() end end end diff --git a/priv/repo/migrations/20211111191749_fill_vf_scenario_definition.exs b/priv/repo/migrations/20211111191749_fill_vf_scenario_definition.exs @@ -30,6 +30,7 @@ def change() do add :note, :text add :has_duration_unit_type, :vf_time_unit add :has_duration_numeric_duration, :float + timestamps() end create constraint("vf_scenario_definition", :has_duration, check: @check) diff --git a/priv/repo/migrations/20211111194625_fill_vf_scenario.exs b/priv/repo/migrations/20211111194625_fill_vf_scenario.exs @@ -27,6 +27,7 @@ def change() do add :defined_as_id, references("vf_scenario_definition") add :refinement_of_id, references("vf_scenario") # :in_scope_of + timestamps() end end end diff --git a/priv/repo/migrations/20211112115624_fill_vf_plan.exs b/priv/repo/migrations/20211112115624_fill_vf_plan.exs @@ -25,6 +25,7 @@ def change() do add :created, :timestamptz add :due, :timestamptz add :refinement_of_id, references("vf_scenario") + timestamps() end end end diff --git a/priv/repo/migrations/20211112185747_fill_vf_process.exs b/priv/repo/migrations/20211112185747_fill_vf_process.exs @@ -30,6 +30,7 @@ def change() do add :planned_within_id, references("vf_plan") add :nested_in_id, references("vf_scenario") # :in_scope_of + timestamps() end end end diff --git a/priv/repo/migrations/20211113064700_fill_vf_product_batch.exs b/priv/repo/migrations/20211113064700_fill_vf_product_batch.exs @@ -23,6 +23,7 @@ def change() do add :batch_number, :text, null: false add :expiry_date, :timestamptz add :production_date, :timestamptz + timestamps() end end end diff --git a/priv/repo/migrations/20211113071804_fill_vf_economic_resource.exs b/priv/repo/migrations/20211113071804_fill_vf_economic_resource.exs @@ -38,6 +38,7 @@ def change() do add :lot_id, references("vf_product_batch") add :contained_in_id, references("vf_economic_resource") add :unit_of_effort_id, references("vf_unit") + timestamps() end end end diff --git a/priv/repo/migrations/20211114144908_fill_vf_economic_event.exs b/priv/repo/migrations/20211114144908_fill_vf_economic_event.exs @@ -43,6 +43,7 @@ def change() do add :triggered_by_id, references("vf_economic_event") # add :in_scope_of add :agreed_in, :text + timestamps() end end end diff --git a/priv/repo/migrations/20211114165810_fill_vf_appreciation.exs b/priv/repo/migrations/20211114165810_fill_vf_appreciation.exs @@ -23,6 +23,7 @@ def change() do add :appreciation_of_id, references("vf_economic_event"), null: false add :appreciation_with_id, references("vf_economic_event"), null: false add :note, :text + timestamps() end end end diff --git a/priv/repo/migrations/20211114190636_fill_vf_intent.exs b/priv/repo/migrations/20211114190636_fill_vf_intent.exs @@ -45,6 +45,7 @@ def change() do add :note, :text # add :in_scope_of add :agreed_in, :text + timestamps() end end end diff --git a/priv/repo/migrations/20211115055335_fill_vf_commitment.exs b/priv/repo/migrations/20211115055335_fill_vf_commitment.exs @@ -36,7 +36,6 @@ def change() do add :has_end, :timestamptz add :has_point_in_time, :timestamptz add :due, :timestamptz - timestamps(inserted_at: :created, updated_at: false) add :finished, :boolean, default: false, null: false add :note, :text # add :in_scope_of @@ -44,6 +43,7 @@ def change() do add :independent_demand_of_id, references("vf_plan") add :at_location_id, references("vf_spatial_thing") add :clause_of_id, references("vf_agreement") + timestamps() end end end diff --git a/priv/repo/migrations/20211115071129_fill_vf_fulfillment.exs b/priv/repo/migrations/20211115071129_fill_vf_fulfillment.exs @@ -27,6 +27,7 @@ def change() do add :effort_quantity_has_unit_id, references("vf_unit") add :effort_quantity_has_numerical_value, :float add :note, :text + timestamps() end end end diff --git a/priv/repo/migrations/20211115074158_fill_vf_event_or_commitment.exs b/priv/repo/migrations/20211115074158_fill_vf_event_or_commitment.exs @@ -28,6 +28,7 @@ def change() do alter table("vf_event_or_commitment") do add :event_id, references("vf_economic_event") add :commitment_id, references("vf_commitment") + timestamps() end create constraint("vf_event_or_commitment", :mutex, check: @check) diff --git a/priv/repo/migrations/20211115103758_fill_vf_satisfaction.exs b/priv/repo/migrations/20211115103758_fill_vf_satisfaction.exs @@ -27,6 +27,7 @@ def change() do add :effort_quantity_has_unit_id, references("vf_unit") add :effort_quantity_has_numerical_value, :float add :note, :text + timestamps() end end end diff --git a/priv/repo/migrations/20211115173048_fill_vf_claim.exs b/priv/repo/migrations/20211115173048_fill_vf_claim.exs @@ -36,6 +36,7 @@ def change() do add :note, :text add :agreed_in, :text # add :in_scope_of + timestamps() end end end diff --git a/priv/repo/migrations/20211115181352_fill_vf_settlement.exs b/priv/repo/migrations/20211115181352_fill_vf_settlement.exs @@ -27,6 +27,7 @@ def change() do add :effort_quantity_has_unit_id, references("vf_unit") add :effort_quantity_has_numerical_value, :float add :note, :text + timestamps() end end end diff --git a/priv/repo/migrations/20211115183013_fill_vf_proposal.exs b/priv/repo/migrations/20211115183013_fill_vf_proposal.exs @@ -25,9 +25,9 @@ def change() do add :has_end, :utc_datetime_usec # add :in_scope_of_id add :unit_based, :boolean, default: false, null: false - timestamps(inserted_at: :created, updated_at: false) add :note, :text add :eligible_location_id, references("vf_spatial_thing") + timestamps() end end end diff --git a/priv/repo/migrations/20211115185611_fill_vf_proposed_intent.exs b/priv/repo/migrations/20211115185611_fill_vf_proposed_intent.exs @@ -23,6 +23,7 @@ def change() do add :reciprocal, :boolean, default: false, null: false add :publishes_id, references("vf_intent"), null: false add :published_in_id, references("vf_proposal"), null: false + timestamps() end end end diff --git a/priv/repo/migrations/20211118061736_fill_vf_proposed_to.exs b/priv/repo/migrations/20211118061736_fill_vf_proposed_to.exs @@ -22,6 +22,7 @@ def change() do alter table("vf_proposed_to") do add :proposed_to_id, references("vf_agent"), null: false add :proposed_id, references("vf_proposal"), null: false + timestamps() end end end diff --git a/src/zenflows/vf/agent.ex b/src/zenflows/vf/agent.ex @@ -52,6 +52,7 @@ schema "vf_agent" do field :note, :string field :image, :string belongs_to :primary_location, SpatialThing + timestamps() # person field :user, :string diff --git a/src/zenflows/vf/agent_relationship.ex b/src/zenflows/vf/agent_relationship.ex @@ -43,6 +43,7 @@ schema "vf_agent_relationship" do belongs_to :relationship, AgentRelationshipRole # in_scope_of field :note, :string + timestamps() end @reqr ~w[subject_id object_id relationship_id]a diff --git a/src/zenflows/vf/agent_relationship_role.ex b/src/zenflows/vf/agent_relationship_role.ex @@ -37,6 +37,7 @@ schema "vf_agent_relationship_role" do field :role_label, :string field :inverse_role_label, :string field :note, :string + timestamps() end @reqr [:role_label] diff --git a/src/zenflows/vf/agreement.ex b/src/zenflows/vf/agreement.ex @@ -26,16 +26,15 @@ alias Zenflows.VF.Validate id: String.t(), name: String.t(), note: String.t() | nil, - created: DateTime.t(), } -@reqr ~w[name created]a +@reqr [:name] @cast @reqr ++ [:note] schema "vf_agreement" do field :name, :string field :note, :string - field :created, :utc_datetime_usec + timestamps() end @doc false diff --git a/src/zenflows/vf/agreement/type.ex b/src/zenflows/vf/agreement/type.ex @@ -40,7 +40,7 @@ object :agreement do field :note, :string @desc @created - field :created, non_null(:datetime) + field :inserted_at, non_null(:datetime), name: "created" end object :agreement_response do @@ -53,9 +53,6 @@ input_object :agreement_create_params do @desc @note field :note, :string - - @desc @created - field :created, non_null(:datetime) end input_object :agreement_update_params do @@ -66,9 +63,6 @@ input_object :agreement_update_params do @desc @note field :note, :string - - @desc @created - field :created, :datetime end object :query_agreement do diff --git a/src/zenflows/vf/appreciation.ex b/src/zenflows/vf/appreciation.ex @@ -36,6 +36,7 @@ schema "vf_appreciation" do belongs_to :appreciation_of, EconomicEvent belongs_to :appreciation_with, EconomicEvent field :note, :string + timestamps() end @reqr ~w[appreciation_of_id appreciation_with_id]a diff --git a/src/zenflows/vf/claim.ex b/src/zenflows/vf/claim.ex @@ -43,7 +43,6 @@ alias Zenflows.VF.{ effort_quantity: Measure.t() | nil, triggered_by: EconomicEvent.t(), due: DateTime.t() | nil, - created: DateTime.t() | nil, finished: boolean(), note: String.t() | nil, agreed_in: String.t() | nil, @@ -65,18 +64,18 @@ schema "vf_claim" do field :effort_quantity_has_numerical_value, :float belongs_to :triggered_by, EconomicEvent field :due, :utc_datetime_usec - field :created, :utc_datetime_usec field :finished, :boolean field :note, :string field :agreed_in, :string # field :in_scope_of + timestamps() end @reqr ~w[action_id provider_id receiver_id]a @cast @reqr ++ ~w[ resource_classified_as resource_conforms_to_id resource_quantity effort_quantity - triggered_by_id due created finished note agreed_in + triggered_by_id due finished note agreed_in ]a # in_scope_of @doc false diff --git a/src/zenflows/vf/commitment.ex b/src/zenflows/vf/commitment.ex @@ -52,7 +52,6 @@ alias Zenflows.VF.{ has_end: DateTime.t() | nil, has_point_in_time: DateTime.t() | nil, due: DateTime.t() | nil, - created: DateTime.t() | nil, finished: boolean(), note: String.t() | nil, # in_scope_of: @@ -82,7 +81,6 @@ schema "vf_commitment" do field :has_end, :utc_datetime_usec field :has_point_in_time, :utc_datetime_usec field :due, :utc_datetime_usec - timestamps(inserted_at: :created, updated_at: false) field :finished, :boolean, default: false field :note, :string # field :in_scope_of @@ -90,6 +88,7 @@ schema "vf_commitment" do belongs_to :independent_demand_of, Plan belongs_to :at_location, SpatialThing belongs_to :clause_of, Agreement + timestamps() end @reqr ~w[action_id provider_id receiver_id]a diff --git a/src/zenflows/vf/economic_event.ex b/src/zenflows/vf/economic_event.ex @@ -89,6 +89,7 @@ schema "vf_economic_event" do # field :in_scope_of field :agreed_in, :string belongs_to :triggered_by, EconomicEvent + timestamps() end @insert_reqr ~w[action_id provider_id receiver_id]a diff --git a/src/zenflows/vf/economic_resource.ex b/src/zenflows/vf/economic_resource.ex @@ -79,6 +79,7 @@ schema "vf_economic_resource" do belongs_to :lot, ProductBatch belongs_to :contained_in, EconomicResource belongs_to :unit_of_effort, Unit + timestamps() end @reqr ~w[ diff --git a/src/zenflows/vf/event_or_commitment.ex b/src/zenflows/vf/event_or_commitment.ex @@ -32,6 +32,7 @@ alias Zenflows.VF.{Commitment, EconomicEvent} schema "vf_event_or_commitment" do belongs_to :event, EconomicEvent belongs_to :commitment, Commitment + timestamps() end @cast ~w[event_id commitment_id]a diff --git a/src/zenflows/vf/fulfillment.ex b/src/zenflows/vf/fulfillment.ex @@ -49,6 +49,7 @@ schema "vf_fulfillment" do field :effort_quantity, :map, virtual: true belongs_to :effort_quantity_has_unit, Unit field :effort_quantity_has_numerical_value, :float + timestamps() end @reqr ~w[fulfilled_by_id fulfills_id]a diff --git a/src/zenflows/vf/intent.ex b/src/zenflows/vf/intent.ex @@ -89,6 +89,7 @@ schema "vf_intent" do field :note, :string # field :in_scope_of field :agreed_in, :string + timestamps() end @reqr [:action_id] diff --git a/src/zenflows/vf/organization.ex b/src/zenflows/vf/organization.ex @@ -38,6 +38,7 @@ schema "vf_agent" do field :note, :string belongs_to :primary_location, SpatialThing field :classified_as, {:array, :string} + timestamps() end @reqr [:name] diff --git a/src/zenflows/vf/person.ex b/src/zenflows/vf/person.ex @@ -50,6 +50,7 @@ schema "vf_agent" do field :ethereum_address, :string field :reflow_public_key, :string field :schnorr_public_key, :string + timestamps() end @insert_reqr ~w[name user email]a diff --git a/src/zenflows/vf/plan.ex b/src/zenflows/vf/plan.ex @@ -27,7 +27,6 @@ alias Zenflows.VF.{Scenario, Validate} @type t() :: %__MODULE__{ name: String.t(), - created: DateTime.t() | nil, due: DateTime.t() | nil, note: String.t() | nil, refinement_of: Scenario.t() | nil, @@ -35,14 +34,14 @@ alias Zenflows.VF.{Scenario, Validate} schema "vf_plan" do field :name, :string - field :created, :utc_datetime_usec field :due, :utc_datetime_usec field :note, :string belongs_to :refinement_of, Scenario + timestamps() end @reqr [:name] -@cast @reqr ++ ~w[created due note refinement_of_id]a +@cast @reqr ++ ~w[due note refinement_of_id]a @doc false @spec chgset(Schema.t(), params()) :: Changeset.t() diff --git a/src/zenflows/vf/plan/type.ex b/src/zenflows/vf/plan/type.ex @@ -46,7 +46,7 @@ object :plan do field :note, :string @desc @created - field :created, :datetime + field :inserted_at, non_null(:datetime), name: "created" @desc @due field :due, :datetime @@ -69,9 +69,6 @@ input_object :plan_create_params do @desc @note field :note, :string - @desc @created - field :created, :datetime - @desc @due field :due, :datetime @@ -91,9 +88,6 @@ input_object :plan_update_params do @desc @note field :note, :string - @desc @created - field :created, :datetime - @desc @due field :due, :datetime diff --git a/src/zenflows/vf/process.ex b/src/zenflows/vf/process.ex @@ -56,6 +56,7 @@ schema "vf_process" do # belongs_to :in_scope_of belongs_to :planned_within, Plan belongs_to :nested_in, Scenario + timestamps() has_many :inputs, EconomicEvent, foreign_key: :input_of_id has_many :outputs, EconomicEvent, foreign_key: :output_of_id diff --git a/src/zenflows/vf/process_specification.ex b/src/zenflows/vf/process_specification.ex @@ -32,6 +32,7 @@ alias Zenflows.VF.Validate schema "vf_process_specification" do field :name, :string field :note, :string + timestamps() end @reqr [:name] diff --git a/src/zenflows/vf/product_batch.ex b/src/zenflows/vf/product_batch.ex @@ -35,6 +35,7 @@ schema "vf_product_batch" do field :batch_number, :string field :expiry_date, :utc_datetime_usec field :production_date, :utc_datetime_usec + timestamps() end @reqr [:batch_number] diff --git a/src/zenflows/vf/proposal.ex b/src/zenflows/vf/proposal.ex @@ -22,14 +22,17 @@ Published requests or offers, sometimes with what is expected in return. use Zenflows.DB.Schema -alias Zenflows.VF.{SpatialThing, Validate} +alias Zenflows.VF.{ + ProposedIntent, + SpatialThing, + Validate, +} @type t() :: %__MODULE__{ name: String.t(), has_beginning: DateTime.t() | nil, has_end: DateTime.t() | nil, unit_based: boolean(), - created: DateTime.t(), note: String.t() | nil, eligible_location: SpatialThing.t() | nil, } @@ -39,9 +42,11 @@ schema "vf_proposal" do field :has_beginning, :utc_datetime_usec field :has_end, :utc_datetime_usec field :unit_based, :boolean, default: false - timestamps(inserted_at: :created, updated_at: false) field :note, :string belongs_to :eligible_location, SpatialThing + timestamps() + + has_many :publishes, ProposedIntent, foreign_key: :published_in_id end @cast ~w[name has_beginning has_end unit_based note eligible_location_id]a diff --git a/src/zenflows/vf/proposal/type.ex b/src/zenflows/vf/proposal/type.ex @@ -0,0 +1,177 @@ +# Zenflows is designed to implement the Valueflows vocabulary, +# written and maintained by srfsh <info@dyne.org>. +# Copyright (C) 2021-2022 Dyne.org foundation <foundation@dyne.org>. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +defmodule Zenflows.VF.Proposal.Type do +@moduledoc "GraphQL types of Proposals." + +use Absinthe.Schema.Notation + +alias Zenflows.VF.Proposal.Resolv + +@name """ +An informal or formal textual identifier for a proposal. Does not +imply uniqueness. +""" +@note "A textual description or comment." +@has_beginning "The beginning time of proposal publication." +@has_end "The end time of proposal publication." +@unit_based """ +This proposal contains unit based quantities, which can be multipied to +create commitments; commonly seen in a price list or e-commerce. +""" +@created "The date and time the proposal was created." +@eligible_location "The location at which this proposal is eligible." + +@desc """ +Published requests or offers, sometimes with what is expected in return. +""" +object :proposal do + field :id, non_null(:id) + + @desc @name + field :name, :string + + @desc @note + field :note, :string + + @desc @has_beginning + field :has_beginning, :datetime + + @desc @has_end + field :has_end, :datetime + + @desc @unit_based + field :unit_based, :boolean + + @desc @created + field :inserted_at, :datetime, name: "created" + + @desc @eligible_location + field :eligible_location, resolve: &Resolv.eligible_location/3 + + field :publishes, list_of(non_null(:proposed_intent)), + resolve: &Resolv.publishes/3 +end + +object :proposal_response do + field :proposal, non_null(:proposal) +end + +object :proposal_edge do + field :cursor, non_null(:string) + field :node, non_null(:proposal) +end + +object :proposal_connection do + field :page_info, non_null(:page_info) + field :edges, non_null(list_of(non_null(:proposal_edge))) +end + +input_object :proposal_create_params do + @desc @name + field :name, :string + + @desc @note + field :note, :string + + @desc @has_beginning + field :has_beginning, :datetime + + @desc @has_end + field :has_end, :datetime + + @desc @unit_based + field :unit_based, :boolean + + @desc "(`SpatialThing`) #{@eligible_location}" + field :eligible_location_id, name: "eligible_location" +end + +input_object :proposal_update_params do + field :id, non_null(:id) + + @desc @name + field :name, :string + + @desc @note + field :note, :string + + @desc @has_beginning + field :has_beginning, :datetime + + @desc @has_end + field :has_end, :datetime + + @desc @unit_based + field :unit_based, :boolean + + @desc "(`SpatialThing`) #{@eligible_location}" + field :eligible_location_id, name: "eligible_location" +end + +object :query_proposal do + field :proposal, :proposal do + arg :id, non_null(:id) + resolve &Resolv.proposal/2 + end + + field :proposals, non_null(:proposal_connection) do + arg :first, :integer + arg :after, :string + arg :last, :integer + arg :before, :string + resolve &Resolv.proposals/2 + end + + @desc "List all proposals that are being listed as offers." + field :offers, non_null(:proposal_connection) do + arg :first, :integer + arg :first, :integer + arg :after, :string + arg :last, :integer + arg :before, :string + resolve &Resolv.offers/2 + end + + @desc "List all proposals that are being listed as requests." + field :requests, non_null(:proposal_connection) do + arg :first, :integer + arg :first, :integer + arg :after, :string + arg :last, :integer + arg :before, :string + resolve &Resolv.offers/2 + end +end + +object :mutation_proposal do + field :create_proposal, non_null(:proposal_response) do + arg :proposal, non_null(:proposal_create_params) + resolve &Resolv.create_proposal/2 + end + + field :update_proposal, non_null(:proposal_response) do + arg :proposal, non_null(:proposal_update_params) + resolve &Resolv.update_proposal/2 + end + + field :delete_proposal, non_null(:boolean) do + arg :id, non_null(:id) + resolve &Resolv.delete_proposal/2 + end +end +end diff --git a/src/zenflows/vf/proposed_intent.ex b/src/zenflows/vf/proposed_intent.ex @@ -36,6 +36,7 @@ schema "vf_proposed_intent" do field :reciprocal, :boolean, default: false belongs_to :publishes, Intent belongs_to :published_in, Proposal + timestamps() end @reqr ~w[publishes_id published_in_id]a diff --git a/src/zenflows/vf/proposed_intent/type.ex b/src/zenflows/vf/proposed_intent/type.ex @@ -0,0 +1,65 @@ +# Zenflows is designed to implement the Valueflows vocabulary, +# written and maintained by srfsh <info@dyne.org>. +# Copyright (C) 2021-2022 Dyne.org foundation <foundation@dyne.org>. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +defmodule Zenflows.VF.ProposedIntent.Type do +@moduledoc "GraphQL types of ProposedIntent." + +use Absinthe.Schema.Notation + +alias Zenflows.VF.ProposedIntent.Resolv + +@desc """ +Represents many-to-many relationships between Proposals and Intents, +supporting including intents in multiple proposals, as well as a proposal +including multiple intents. +""" +object :proposed_intent do + field :id, non_null(:id) + + @desc """ + This is a reciprocal intent of this proposal, not primary. Not meant + to be used for intent matching. + """ + field :reciprocal, non_null(:boolean) + + @desc "The published proposal which this intent is part of." + field :published_in, non_null(proposal) +end + +object :proposed_intent_response do + field :proposed_intent, non_null(:proposed_intent) +end + +object :mutation_proposed_intent do + @desc""" + Include an existing intent as part of a proposal. + @param publishedIn the (`Proposal`) to include the intent in + @param publishes the (`Intent`) to include as part of the proposal + """ + field :propose_intent, non_null(:proposed_intent_response) do + arg :published_in_id, non_null(:id), name: "published_in" + arg :publishes_id, non_null(:id), name: "publishes" + arg :reciprocal, :boolean + resolve &Resolv.propose_intent/2 + end + + field :delete_proposed_intent, non_null(:boolean) do + arg :id, non_null(:id) + resolve &Resolv.delete_proposed_intent/2 + end +end +end diff --git a/src/zenflows/vf/proposed_to.ex b/src/zenflows/vf/proposed_to.ex @@ -33,6 +33,7 @@ alias Zenflows.VF.{Agent, Proposal} schema "vf_proposed_to" do belongs_to :proposed_to, Agent belongs_to :proposed, Proposal + timestamps() end @reqr ~w[proposed_to_id proposed_id]a diff --git a/src/zenflows/vf/recipe_exchange.ex b/src/zenflows/vf/recipe_exchange.ex @@ -32,6 +32,7 @@ alias Zenflows.VF.Validate schema "vf_recipe_exchange" do field :name, :string field :note, :string + timestamps() end @reqr [:name] diff --git a/src/zenflows/vf/recipe_flow.ex b/src/zenflows/vf/recipe_flow.ex @@ -57,6 +57,7 @@ schema "vf_recipe_flow" do belongs_to :effort_quantity_has_unit, Unit field :effort_quantity_has_numerical_value, :float belongs_to :recipe_clause_of, RecipeExchange + timestamps() end @reqr ~w[action_id recipe_flow_resource_id]a diff --git a/src/zenflows/vf/recipe_process.ex b/src/zenflows/vf/recipe_process.ex @@ -47,6 +47,7 @@ schema "vf_recipe_process" do field :has_duration, :map, virtual: true field :has_duration_unit_type, TimeUnitEnum field :has_duration_numeric_duration, :float + timestamps() end @reqr ~w[name process_conforms_to_id]a diff --git a/src/zenflows/vf/recipe_resource.ex b/src/zenflows/vf/recipe_resource.ex @@ -48,6 +48,7 @@ schema "vf_recipe_resource" do field :substitutable, :boolean, default: false field :image, :string field :note, :string + timestamps() end @reqr [:name] diff --git a/src/zenflows/vf/resource_specification.ex b/src/zenflows/vf/resource_specification.ex @@ -42,6 +42,7 @@ schema "vf_resource_specification" do field :note, :string belongs_to :default_unit_of_resource, Unit belongs_to :default_unit_of_effort, Unit + timestamps() end @reqr [:name] diff --git a/src/zenflows/vf/role_behavior.ex b/src/zenflows/vf/role_behavior.ex @@ -32,6 +32,7 @@ alias Zenflows.VF.Validate schema "vf_role_behavior" do field :name, :string field :note, :string + timestamps() end @reqr [:name] diff --git a/src/zenflows/vf/satisfaction.ex b/src/zenflows/vf/satisfaction.ex @@ -49,6 +49,7 @@ schema "vf_satisfaction" do belongs_to :effort_quantity_has_unit, Unit field :effort_quantity_has_numerical_value, :float field :note, :string + timestamps() end @reqr ~w[satisfied_by_id satisfies_id]a diff --git a/src/zenflows/vf/scenario.ex b/src/zenflows/vf/scenario.ex @@ -46,6 +46,7 @@ schema "vf_scenario" do # field :in_scope_of belongs_to :defined_as, ScenarioDefinition belongs_to :refinement_of, Scenario + timestamps() end @reqr [:name] diff --git a/src/zenflows/vf/scenario_definition.ex b/src/zenflows/vf/scenario_definition.ex @@ -42,6 +42,7 @@ schema "vf_scenario_definition" do field :has_duration, :map, virtual: true field :has_duration_unit_type, TimeUnitEnum field :has_duration_numeric_duration, :float + timestamps() end @reqr [:name] diff --git a/src/zenflows/vf/settlement.ex b/src/zenflows/vf/settlement.ex @@ -49,6 +49,7 @@ schema "vf_settlement" do belongs_to :effort_quantity_has_unit, Unit field :effort_quantity_has_numerical_value, :float field :note, :string + timestamps() end @reqr ~w[settled_by_id settles_id]a diff --git a/src/zenflows/vf/spatial_thing.ex b/src/zenflows/vf/spatial_thing.ex @@ -44,6 +44,7 @@ schema "vf_spatial_thing" do field :long, :float field :alt, :float field :note, :string + timestamps() end @doc false diff --git a/src/zenflows/vf/unit.ex b/src/zenflows/vf/unit.ex @@ -34,6 +34,7 @@ alias Zenflows.VF.Validate schema "vf_unit" do field :label, :string field :symbol, :string + timestamps() end @reqr ~w[label symbol]a diff --git a/test/help/factory.ex b/test/help/factory.ex @@ -291,7 +291,6 @@ end def build(:agreement) do %VF.Agreement{ name: uniq("some name"), - created: DateTime.utc_now(), note: uniq("some note"), } end @@ -322,7 +321,6 @@ end def build(:plan) do %VF.Plan{ name: uniq("some name"), - created: DateTime.utc_now(), due: DateTime.utc_now(), note: uniq("some note"), refinement_of: build(:scenario), @@ -513,7 +511,6 @@ def build(:claim) do effort_quantity_has_numerical_value: effqty.has_numerical_value, triggered_by: if(bool(), do: build(:economic_event), else: nil), due: DateTime.utc_now(), - created: DateTime.utc_now(), finished: bool(), agreed_in: uniq("some uri"), note: uniq("some note"), diff --git a/test/vf/agreement/domain.test.exs b/test/vf/agreement/domain.test.exs @@ -26,7 +26,6 @@ setup do params: %{ name: Factory.uniq("name"), note: Factory.uniq("note"), - created: DateTime.utc_now(), }, inserted: Factory.insert!(:agreement), } @@ -42,7 +41,6 @@ describe "create/1" do assert agreem.name == params.name assert agreem.note == params.note - assert agreem.created == params.created end test "doesn't create a Agreement with invalid params" do @@ -56,7 +54,6 @@ describe "update/2" do assert new.name == params.name assert new.note == params.note - assert new.created == params.created end test "doesn't update a Agreement", %{inserted: old} do @@ -64,7 +61,6 @@ describe "update/2" do assert new.name == old.name assert new.note == old.note - assert new.created == old.created end end diff --git a/test/vf/agreement/type.test.exs b/test/vf/agreement/type.test.exs @@ -23,7 +23,6 @@ setup do params: %{ name: Factory.uniq("name"), note: Factory.uniq("note"), - created: DateTime.utc_now(), }, agreement: Factory.insert!(:agreement), } @@ -44,7 +43,6 @@ describe "Query" do assert data["id"] == agreem.id assert data["name"] == agreem.name assert data["note"] == agreem.note - assert data["created"] == DateTime.to_iso8601(agreem.created) end end @@ -55,7 +53,6 @@ describe "Mutation" do createAgreement(agreement: { name: "#{params.name}" note: "#{params.note}" - created: "#{params.created}" }) { agreement { id @@ -69,7 +66,6 @@ describe "Mutation" do assert {:ok, _} = Zenflows.DB.ID.cast(data["id"]) assert data["name"] == params.name assert data["note"] == params.note - assert data["created"] == DateTime.to_iso8601(params.created) end test "updateAgreement()", %{params: params, agreement: agreem} do @@ -79,7 +75,6 @@ describe "Mutation" do id: "#{agreem.id}" name: "#{params.name}" note: "#{params.note}" - created: "#{params.created}" }) { agreement { id @@ -93,7 +88,6 @@ describe "Mutation" do assert data["id"] == agreem.id assert data["name"] == params.name assert data["note"] == params.note - assert data["created"] == DateTime.to_iso8601(params.created) end test "deleteAgreement()", %{agreement: %{id: id}} do diff --git a/test/vf/claim.test.exs b/test/vf/claim.test.exs @@ -37,7 +37,6 @@ setup do }, triggered_by_id: Factory.insert!(:economic_event).id, due: DateTime.utc_now(), - created: DateTime.utc_now(), finished: Factory.bool(), note: Factory.uniq("note"), agreed_in: Factory.uniq("uri"), @@ -63,7 +62,6 @@ test "create Claim", %{params: params} do assert claim.effort_quantity_has_numerical_value == params.effort_quantity.has_numerical_value assert claim.triggered_by_id == params.triggered_by_id assert claim.due == params.due - assert claim.created == params.created assert claim.finished == params.finished assert claim.note == params.note assert claim.agreed_in == params.agreed_in @@ -89,7 +87,6 @@ test "update Appreciation", %{params: params} do assert claim.effort_quantity_has_numerical_value == params.effort_quantity.has_numerical_value assert claim.triggered_by_id == params.triggered_by_id assert claim.due == params.due - assert claim.created == params.created assert claim.finished == params.finished assert claim.note == params.note assert claim.agreed_in == params.agreed_in diff --git a/test/vf/commitment.test.exs b/test/vf/commitment.test.exs @@ -101,7 +101,6 @@ describe "create Commitment" do assert comm.has_end == nil assert comm.has_point_in_time == params.has_point_in_time assert comm.due == params.due - assert DateTime.compare(comm.created, DateTime.utc_now()) != :gt assert comm.finished == params.finished assert comm.note == params.note # assert in_scope_of_id @@ -135,7 +134,6 @@ describe "create Commitment" do assert comm.has_end == nil assert comm.has_point_in_time == nil assert comm.due == params.due - assert DateTime.compare(comm.created, DateTime.utc_now()) != :gt assert comm.finished == params.finished assert comm.note == params.note # assert in_scope_of_id @@ -169,7 +167,6 @@ describe "create Commitment" do assert comm.has_end == params.has_end assert comm.has_point_in_time == nil assert comm.due == params.due - assert DateTime.compare(comm.created, DateTime.utc_now()) != :gt assert comm.finished == params.finished assert comm.note == params.note # assert in_scope_of_id @@ -205,7 +202,6 @@ describe "create Commitment" do assert comm.has_end == params.has_end assert comm.has_point_in_time == nil assert comm.due == params.due - assert DateTime.compare(comm.created, DateTime.utc_now()) != :gt assert comm.finished == params.finished assert comm.note == params.note # assert in_scope_of_id @@ -256,7 +252,6 @@ describe "create Commitment" do assert comm.has_end == nil assert comm.has_point_in_time == params.has_point_in_time assert comm.due == params.due - assert DateTime.compare(comm.created, DateTime.utc_now()) != :gt assert comm.finished == params.finished assert comm.note == params.note # assert in_scope_of_id @@ -292,7 +287,6 @@ describe "create Commitment" do assert comm.has_end == nil assert comm.has_point_in_time == params.has_point_in_time assert comm.due == params.due - assert DateTime.compare(comm.created, DateTime.utc_now()) != :gt assert comm.finished == params.finished assert comm.note == params.note # assert in_scope_of_id @@ -327,7 +321,6 @@ test "with present assocs", %{params: params} do assert new.has_end == old.has_end assert new.has_point_in_time == old.has_point_in_time assert new.due == params.due - assert DateTime.compare(new.created, DateTime.utc_now()) != :gt assert new.finished == params.finished assert new.note == params.note # assert in_scope_of_id diff --git a/test/vf/plan/domain.test.exs b/test/vf/plan/domain.test.exs @@ -25,7 +25,6 @@ setup ctx do params = %{ name: Factory.uniq("name"), note: Factory.uniq("note"), - created: DateTime.utc_now(), due: DateTime.utc_now(), refinement_of_id: Factory.insert!(:scenario).id, } @@ -48,7 +47,6 @@ describe "create/1" do assert plan.name == params.name assert plan.note == params.note - assert plan.created == params.created assert plan.due == params.due assert plan.refinement_of_id == params.refinement_of_id end @@ -64,7 +62,6 @@ describe "update/2" do assert new.name == params.name assert new.note == params.note - assert new.created == params.created assert new.due == params.due assert new.refinement_of_id == params.refinement_of_id end @@ -74,7 +71,6 @@ describe "update/2" do assert new.name == old.name assert new.note == old.note - assert new.created == old.created assert new.due == old.due assert new.refinement_of_id == old.refinement_of_id end diff --git a/test/vf/plan/type.test.exs b/test/vf/plan/type.test.exs @@ -23,7 +23,6 @@ setup do params: %{ name: Factory.uniq("name"), note: Factory.uniq("note"), - created: DateTime.utc_now(), due: DateTime.utc_now(), refinement_of_id: Factory.insert!(:scenario).id, }, @@ -61,7 +60,6 @@ describe "Mutation" do createPlan(plan: { name: "#{params.name}" note: "#{params.note}" - created: "#{params.created}" due: "#{params.due}" refinementOf: "#{params.refinement_of_id}" }) { @@ -79,7 +77,6 @@ describe "Mutation" do assert {:ok, _} = Zenflows.DB.ID.cast(data["id"]) assert data["name"] == params.name assert data["note"] == params.note - assert data["created"] == DateTime.to_iso8601(params.created) assert data["due"] == DateTime.to_iso8601(params.due) assert data["refinementOf"]["id"] == params.refinement_of_id end @@ -91,7 +88,6 @@ describe "Mutation" do id: "#{plan.id}" name: "#{params.name}" note: "#{params.note}" - created: "#{params.created}" due: "#{params.due}" refinementOf: "#{params.refinement_of_id}" }) { @@ -109,7 +105,6 @@ describe "Mutation" do assert data["id"] == plan.id assert data["name"] == params.name assert data["note"] == params.note - assert data["created"] == DateTime.to_iso8601(params.created) assert data["due"] == DateTime.to_iso8601(params.due) assert data["refinementOf"]["id"] == params.refinement_of_id end