Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
C
CommonsPub Federated Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bonfire
CommonsPub Federated Server
Commits
dd976d9a
Commit
dd976d9a
authored
Nov 12, 2020
by
Mayel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix inScopeOf, add attr_get_id, more intent testing
parent
3fb0dcf7
Pipeline
#215275517
failed with stage
in 1 minute and 4 seconds
Changes
20
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
99 additions
and
72 deletions
+99
-72
lib/extensions/profiles/profile.ex
lib/extensions/profiles/profile.ex
+1
-1
lib/extensions/users/user.ex
lib/extensions/users/user.ex
+1
-1
lib/extensions/value_flows/claim/claims.ex
lib/extensions/value_flows/claim/claims.ex
+4
-4
lib/extensions/value_flows/hydration.ex
lib/extensions/value_flows/hydration.ex
+13
-12
lib/extensions/value_flows/knowledge/process_specification/process_specs.ex
...ue_flows/knowledge/process_specification/process_specs.ex
+1
-1
lib/extensions/value_flows/knowledge/resource_specification/resource_spec.ex
...e_flows/knowledge/resource_specification/resource_spec.ex
+4
-4
lib/extensions/value_flows/knowledge/resource_specification/resource_specs.ex
..._flows/knowledge/resource_specification/resource_specs.ex
+1
-1
lib/extensions/value_flows/observation/event/events.ex
lib/extensions/value_flows/observation/event/events.ex
+11
-11
lib/extensions/value_flows/observation/process/processes.ex
lib/extensions/value_flows/observation/process/processes.ex
+2
-2
lib/extensions/value_flows/observation/resource/resources.ex
lib/extensions/value_flows/observation/resource/resources.ex
+7
-7
lib/extensions/value_flows/planning/intent/intents.ex
lib/extensions/value_flows/planning/intent/intents.ex
+9
-9
lib/extensions/value_flows/proposal/proposals.ex
lib/extensions/value_flows/proposal/proposals.ex
+2
-2
lib/extensions/value_flows/schema.gql
lib/extensions/value_flows/schema.gql
+1
-1
lib/extensions/value_flows/util/graphql.ex
lib/extensions/value_flows/util/graphql.ex
+6
-2
lib/mixology/common/common.ex
lib/mixology/common/common.ex
+14
-1
lib/mixology/graphql/phases/execution_resolution.ex
lib/mixology/graphql/phases/execution_resolution.ex
+1
-1
test/value_flows/agent/person/person_graphql_test.exs
test/value_flows/agent/person/person_graphql_test.exs
+1
-3
test/value_flows/observation/event/events_graphql_test.exs
test/value_flows/observation/event/events_graphql_test.exs
+2
-2
test/value_flows/planning/intent/intent_graphql_test.exs
test/value_flows/planning/intent/intent_graphql_test.exs
+16
-5
test/value_flows/proposal/proposal_graphql_test.exs
test/value_flows/proposal/proposal_graphql_test.exs
+2
-2
No files found.
lib/extensions/profiles/profile.ex
View file @
dd976d9a
...
...
@@ -63,7 +63,7 @@ defmodule CommonsPub.Profiles.Profile do
|>
Changeset
.
validate_required
(
@required
)
|>
Changeset
.
change
(
creator_id:
creator
.
id
,
geolocation_id:
Map
.
get
(
attrs
,
:geolocation
),
# TODO: validate location
geolocation_id:
CommonsPub
.
Common
.
attr_get_id
(
attrs
,
:geolocation
),
# TODO: validate location
is_public:
true
)
|>
common_changeset
()
...
...
lib/extensions/users/user.ex
View file @
dd976d9a
...
...
@@ -103,7 +103,7 @@ defmodule CommonsPub.Users.User do
|>
change_public
()
|>
Changeset
.
change
(
# TODO: validate location
geolocation_id:
Map
.
get
(
attrs
,
:geolocation
)
geolocation_id:
CommonsPub
.
Common
.
attr_get_id
(
attrs
,
:geolocation
)
)
end
...
...
lib/extensions/value_flows/claim/claims.ex
View file @
dd976d9a
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Claim
.
Claims
do
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
]
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
,
attr_get_id:
2
]
alias
CommonsPub
.
Repo
alias
CommonsPub
.
Users
.
User
...
...
@@ -51,11 +51,11 @@ defmodule ValueFlows.Claim.Claims do
defp
prepare_attrs
(
attrs
)
do
attrs
|>
maybe_put
(
:action_id
,
Map
.
get
(
attrs
,
:action
))
|>
maybe_put
(
:action_id
,
attr_get_id
(
attrs
,
:action
))
|>
maybe_put
(
:context_id
,
attrs
|>
Map
.
get
(
:in_scope_of
)
|>
CommonsPub
.
Common
.
maybe
(
&
List
.
first
/
1
)
)
|>
maybe_put
(
:resource_conforms_to_id
,
Map
.
get
(
attrs
,
:resource_conforms_to
))
|>
maybe_put
(
:triggered_by_id
,
Map
.
get
(
attrs
,
:triggered_by
))
|>
maybe_put
(
:resource_conforms_to_id
,
attr_get_id
(
attrs
,
:resource_conforms_to
))
|>
maybe_put
(
:triggered_by_id
,
attr_get_id
(
attrs
,
:triggered_by
))
end
end
lib/extensions/value_flows/hydration.ex
View file @
dd976d9a
...
...
@@ -5,8 +5,6 @@ defmodule ValueFlows.Hydration do
UsersResolver
}
alias
CommonsPub
.
Users
.
User
alias
CommonsPub
.
Communities
.
Community
alias
ValueFlows
.
Observation
.
{
Process
,
...
...
@@ -74,7 +72,7 @@ defmodule ValueFlows.Hydration do
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
canonical_url_edge
/
3
],
in_scope_of:
[
resolve:
&
CommonResolver
.
context
_edge
/
3
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
scope
_edge
/
3
],
eligible_location:
[
resolve:
&
ValueFlows
.
Proposal
.
GraphQL
.
eligible_location_edge
/
3
...
...
@@ -106,7 +104,7 @@ defmodule ValueFlows.Hydration do
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
at_location_edge
/
3
],
in_scope_of:
[
resolve:
&
CommonResolver
.
context
_edge
/
3
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
scope
_edge
/
3
],
image:
[
resolve:
&
UploadResolver
.
image_content_edge
/
3
...
...
@@ -165,7 +163,7 @@ defmodule ValueFlows.Hydration do
resolve:
&
ValueFlows
.
Claim
.
GraphQL
.
fetch_triggered_by_edge
/
3
,
],
in_scope_of:
[
resolve:
&
CommonResolver
.
context
_edge
/
3
,
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
scope
_edge
/
3
,
],
creator:
[
resolve:
&
UsersResolver
.
creator_edge
/
3
...
...
@@ -194,7 +192,7 @@ defmodule ValueFlows.Hydration do
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
effort_quantity_edge
/
3
],
in_scope_of:
[
resolve:
&
CommonResolver
.
context
_edge
/
3
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
scope
_edge
/
3
],
input_of:
[
resolve:
&
ValueFlows
.
Observation
.
EconomicEvent
.
GraphQL
.
fetch_input_of_edge
/
3
...
...
@@ -237,7 +235,7 @@ defmodule ValueFlows.Hydration do
resolve:
&
ValueFlows
.
Observation
.
EconomicResource
.
GraphQL
.
fetch_state_edge
/
3
],
in_scope_of:
[
resolve:
&
CommonResolver
.
context
_edge
/
3
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
scope
_edge
/
3
],
classified_as:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
fetch_classifications_edge
/
3
...
...
@@ -284,7 +282,7 @@ defmodule ValueFlows.Hydration do
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
canonical_url_edge
/
3
],
in_scope_of:
[
resolve:
&
CommonResolver
.
context
_edge
/
3
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
scope
_edge
/
3
],
classified_as:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
fetch_classifications_edge
/
3
...
...
@@ -556,15 +554,18 @@ defmodule ValueFlows.Hydration do
:organization
|
:person
def
agent_resolve_type
(%{
agent_type:
:person
},
_
),
do
:
:person
def
agent_resolve_type
(%{
agent_type:
:organization
},
_
),
do
:
:organization
def
agent_resolve_type
(%
Organisation
{},
_
),
do
:
:organization
def
agent_resolve_type
(%
CommonsPub
.
Users
.
User
{},
_
),
do
:
:person
def
agent_resolve_type
(
_
,
_
),
do
:
:person
# def agent_resolve_type(%User{}, _), do: :user
# def person_is_type_of(_), do: true
# def organization_is_type_of(_), do: true
# def resolve_context_type(%Organisation{}, _), do: :organisation
def
resolve_context_type
(%
Community
{},
_
),
do
:
:community
def
resolve_context_type
(%
User
{},
_
),
do
:
:user
def
resolve_context_type
(%
CommonsPub
.
Users
.
User
{},
_
),
do
:
:person
def
resolve_context_type
(%
Organisation
{},
_
),
do
:
:organization
def
resolve_context_type
(%
CommonsPub
.
Communities
.
Community
{},
_
),
do
:
:community
def
resolve_context_type
(%
CommonsPub
.
Collections
.
Collection
{},
_
),
do
:
:collection
def
resolve_context_type
(
_
,
_
),
do
:
:agent
def
production_flow_item_resolve_type
(%
EconomicResource
{},
_
),
do
:
:economic_resource
def
production_flow_item_resolve_type
(%
Process
{},
_
),
do
:
:process
...
...
lib/extensions/value_flows/knowledge/process_specification/process_specs.ex
View file @
dd976d9a
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Knowledge
.
ProcessSpecification
.
ProcessSpecifications
do
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
]
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
,
attr_get_id:
2
]
alias
CommonsPub
.
{
Activities
,
Common
,
Feeds
,
Repo
}
alias
CommonsPub
.
GraphQL
.
{
Fields
,
Page
}
...
...
lib/extensions/value_flows/knowledge/resource_specification/resource_spec.ex
View file @
dd976d9a
...
...
@@ -62,7 +62,7 @@ defmodule ValueFlows.Knowledge.ResourceSpecification do
|>
Changeset
.
validate_required
(
@required
)
|>
Changeset
.
change
(
creator_id:
creator
.
id
,
default_unit_of_effort_id:
Map
.
get
(
attrs
,
:default_unit_of_effort
),
default_unit_of_effort_id:
CommonsPub
.
Common
.
attr_get_id
(
attrs
,
:default_unit_of_effort
),
context_id:
context
.
id
,
is_public:
true
)
...
...
@@ -78,7 +78,7 @@ defmodule ValueFlows.Knowledge.ResourceSpecification do
|>
Changeset
.
validate_required
(
@required
)
|>
Changeset
.
change
(
creator_id:
creator
.
id
,
default_unit_of_effort_id:
Map
.
get
(
attrs
,
:default_unit_of_effort
),
default_unit_of_effort_id:
CommonsPub
.
Common
.
attr_get_id
(
attrs
,
:default_unit_of_effort
),
is_public:
true
)
|>
common_changeset
()
...
...
@@ -93,7 +93,7 @@ defmodule ValueFlows.Knowledge.ResourceSpecification do
|>
Changeset
.
cast
(
attrs
,
@cast
)
|>
Changeset
.
change
(
context_id:
context
.
id
,
default_unit_of_effort_id:
Map
.
get
(
attrs
,
:default_unit_of_effort
)
default_unit_of_effort_id:
CommonsPub
.
Common
.
attr_get_id
(
attrs
,
:default_unit_of_effort
)
)
|>
common_changeset
()
end
...
...
@@ -101,7 +101,7 @@ defmodule ValueFlows.Knowledge.ResourceSpecification do
def
update_changeset
(%
ResourceSpecification
{}
=
resource_spec
,
attrs
)
do
resource_spec
|>
Changeset
.
cast
(
attrs
,
@cast
)
|>
Changeset
.
change
(
default_unit_of_effort_id:
Map
.
get
(
attrs
,
:default_unit_of_effort
))
|>
Changeset
.
change
(
default_unit_of_effort_id:
CommonsPub
.
Common
.
attr_get_id
(
attrs
,
:default_unit_of_effort
))
|>
common_changeset
()
end
...
...
lib/extensions/value_flows/knowledge/resource_specification/resource_specs.ex
View file @
dd976d9a
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Knowledge
.
ResourceSpecification
.
ResourceSpecifications
do
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
]
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
,
attr_get_id:
2
]
alias
CommonsPub
.
{
Activities
,
Common
,
Feeds
,
Repo
}
alias
CommonsPub
.
GraphQL
.
{
Fields
,
Page
}
...
...
lib/extensions/value_flows/observation/event/events.ex
View file @
dd976d9a
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Observation
.
EconomicEvent
.
EconomicEvents
do
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
]
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
,
attr_get_id:
2
]
alias
CommonsPub
.
{
Activities
,
Common
,
Feeds
,
Repo
}
alias
CommonsPub
.
GraphQL
.
{
Fields
,
Page
}
...
...
@@ -367,19 +367,19 @@ defmodule ValueFlows.Observation.EconomicEvent.EconomicEvents do
defp
prepare_attrs
(
attrs
)
do
attrs
|>
maybe_put
(
:action_id
,
Map
.
get
(
attrs
,
:action
))
|>
maybe_put
(
:action_id
,
attr_get_id
(
attrs
,
:action
))
|>
maybe_put
(
:context_id
,
attrs
|>
Map
.
get
(
:in_scope_of
)
|>
CommonsPub
.
Common
.
maybe
(
&
List
.
first
/
1
)
)
|>
maybe_put
(
:provider_id
,
Map
.
get
(
attrs
,
:provider
))
|>
maybe_put
(
:receiver_id
,
Map
.
get
(
attrs
,
:receiver
))
|>
maybe_put
(
:input_of_id
,
Map
.
get
(
attrs
,
:input_of
))
|>
maybe_put
(
:output_of_id
,
Map
.
get
(
attrs
,
:output_of
))
|>
maybe_put
(
:resource_conforms_to_id
,
Map
.
get
(
attrs
,
:resource_conforms_to
))
|>
maybe_put
(
:resource_inventoried_as_id
,
Map
.
get
(
attrs
,
:resource_inventoried_as
))
|>
maybe_put
(
:to_resource_inventoried_as_id
,
Map
.
get
(
attrs
,
:to_resource_inventoried_as
))
|>
maybe_put
(
:triggered_by_id
,
Map
.
get
(
attrs
,
:triggered_by
))
|>
maybe_put
(
:at_location_id
,
Map
.
get
(
attrs
,
:at_location
))
|>
maybe_put
(
:provider_id
,
attr_get_id
(
attrs
,
:provider
))
|>
maybe_put
(
:receiver_id
,
attr_get_id
(
attrs
,
:receiver
))
|>
maybe_put
(
:input_of_id
,
attr_get_id
(
attrs
,
:input_of
))
|>
maybe_put
(
:output_of_id
,
attr_get_id
(
attrs
,
:output_of
))
|>
maybe_put
(
:resource_conforms_to_id
,
attr_get_id
(
attrs
,
:resource_conforms_to
))
|>
maybe_put
(
:resource_inventoried_as_id
,
attr_get_id
(
attrs
,
:resource_inventoried_as
))
|>
maybe_put
(
:to_resource_inventoried_as_id
,
attr_get_id
(
attrs
,
:to_resource_inventoried_as
))
|>
maybe_put
(
:triggered_by_id
,
attr_get_id
(
attrs
,
:triggered_by
))
|>
maybe_put
(
:at_location_id
,
attr_get_id
(
attrs
,
:at_location
))
|>
parse_measurement_attrs
()
end
...
...
lib/extensions/value_flows/observation/process/processes.ex
View file @
dd976d9a
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Observation
.
Process
.
Processes
do
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
]
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
,
attr_get_id:
2
]
alias
CommonsPub
.
{
Activities
,
Common
,
Feeds
,
Repo
}
alias
CommonsPub
.
GraphQL
.
{
Fields
,
Page
}
...
...
@@ -217,7 +217,7 @@ defmodule ValueFlows.Observation.Process.Processes do
defp
prepare_attrs
(
attrs
)
do
attrs
|>
maybe_put
(
:based_on_id
,
Map
.
get
(
attrs
,
:based_on
))
|>
maybe_put
(
:based_on_id
,
attr_get_id
(
attrs
,
:based_on
))
|>
maybe_put
(
:context_id
,
attrs
|>
Map
.
get
(
:in_scope_of
)
|>
CommonsPub
.
Common
.
maybe
(
&
List
.
first
/
1
)
)
...
...
lib/extensions/value_flows/observation/resource/resources.ex
View file @
dd976d9a
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Observation
.
EconomicResource
.
EconomicResources
do
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
]
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
,
attr_get_id:
2
]
alias
CommonsPub
.
{
Activities
,
Common
,
Feeds
,
Repo
}
alias
CommonsPub
.
GraphQL
.
{
Fields
,
Page
}
...
...
@@ -212,15 +212,15 @@ defmodule ValueFlows.Observation.EconomicResource.EconomicResources do
defp
prepare_attrs
(
attrs
)
do
attrs
|>
maybe_put
(
:primary_accountable_id
,
Map
.
get
(
attrs
,
:primary_accountable
))
|>
maybe_put
(
:primary_accountable_id
,
attr_get_id
(
attrs
,
:primary_accountable
))
|>
maybe_put
(
:context_id
,
attrs
|>
Map
.
get
(
:in_scope_of
)
|>
CommonsPub
.
Common
.
maybe
(
&
List
.
first
/
1
)
)
|>
maybe_put
(
:current_location_id
,
Map
.
get
(
attrs
,
:current_location
))
|>
maybe_put
(
:conforms_to_id
,
Map
.
get
(
attrs
,
:conforms_to
))
|>
maybe_put
(
:contained_in_id
,
Map
.
get
(
attrs
,
:contained_in
))
|>
maybe_put
(
:unit_of_effort_id
,
Map
.
get
(
attrs
,
:unit_of_effort
))
|>
maybe_put
(
:state_id
,
Map
.
get
(
attrs
,
:state
))
|>
maybe_put
(
:current_location_id
,
attr_get_id
(
attrs
,
:current_location
))
|>
maybe_put
(
:conforms_to_id
,
attr_get_id
(
attrs
,
:conforms_to
))
|>
maybe_put
(
:contained_in_id
,
attr_get_id
(
attrs
,
:contained_in
))
|>
maybe_put
(
:unit_of_effort_id
,
attr_get_id
(
attrs
,
:unit_of_effort
))
|>
maybe_put
(
:state_id
,
attr_get_id
(
attrs
,
:state
))
|>
parse_measurement_attrs
()
end
...
...
lib/extensions/value_flows/planning/intent/intents.ex
View file @
dd976d9a
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Planning
.
Intent
.
Intents
do
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
]
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
,
attr_get_id:
2
]
alias
CommonsPub
.
{
Activities
,
Common
,
Feeds
,
Repo
}
alias
CommonsPub
.
GraphQL
.
{
Fields
,
Page
}
...
...
@@ -195,17 +195,17 @@ defmodule ValueFlows.Planning.Intent.Intents do
defp
prepare_attrs
(
attrs
)
do
attrs
|>
maybe_put
(
:action_id
,
Map
.
get
(
attrs
,
:action
))
|>
maybe_put
(
:action_id
,
attr_get_id
(
attrs
,
:action
))
|>
maybe_put
(
:context_id
,
attrs
|>
Map
.
get
(
:in_scope_of
)
|>
CommonsPub
.
Common
.
maybe
(
&
List
.
first
/
1
)
)
|>
maybe_put
(
:at_location_id
,
Map
.
get
(
attrs
,
:at_location
))
|>
maybe_put
(
:provider_id
,
Map
.
get
(
attrs
,
:provider
))
|>
maybe_put
(
:receiver_id
,
Map
.
get
(
attrs
,
:receiver
))
|>
maybe_put
(
:input_of_id
,
Map
.
get
(
attrs
,
:input_of
))
|>
maybe_put
(
:output_of_id
,
Map
.
get
(
attrs
,
:output_of
))
|>
maybe_put
(
:resource_conforms_to_id
,
Map
.
get
(
attrs
,
:resource_conforms_to
))
|>
maybe_put
(
:resource_inventoried_as_id
,
Map
.
get
(
attrs
,
:resource_inventoried_as
))
|>
maybe_put
(
:at_location_id
,
attr_get_id
(
attrs
,
:at_location
))
|>
maybe_put
(
:provider_id
,
attr_get_id
(
attrs
,
:provider
))
|>
maybe_put
(
:receiver_id
,
attr_get_id
(
attrs
,
:receiver
))
|>
maybe_put
(
:input_of_id
,
attr_get_id
(
attrs
,
:input_of
))
|>
maybe_put
(
:output_of_id
,
attr_get_id
(
attrs
,
:output_of
))
|>
maybe_put
(
:resource_conforms_to_id
,
attr_get_id
(
attrs
,
:resource_conforms_to
))
|>
maybe_put
(
:resource_inventoried_as_id
,
attr_get_id
(
attrs
,
:resource_inventoried_as
))
|>
parse_measurement_attrs
()
end
...
...
lib/extensions/value_flows/proposal/proposals.ex
View file @
dd976d9a
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Proposal
.
Proposals
do
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
]
import
CommonsPub
.
Common
,
only:
[
maybe_put:
3
,
attr_get_id:
2
]
alias
CommonsPub
.
{
Activities
,
Common
,
Feeds
,
Repo
}
alias
CommonsPub
.
GraphQL
.
{
Fields
,
Page
}
...
...
@@ -244,6 +244,6 @@ defmodule ValueFlows.Proposal.Proposals do
|>
maybe_put
(
:context_id
,
attrs
|>
Map
.
get
(
:in_scope_of
)
|>
CommonsPub
.
Common
.
maybe
(
&
List
.
first
/
1
)
)
|>
maybe_put
(
:eligible_location_id
,
Map
.
get
(
attrs
,
:eligible_location
))
|>
maybe_put
(
:eligible_location_id
,
attr_get_id
(
attrs
,
:eligible_location
))
end
end
lib/extensions/value_flows/schema.gql
View file @
dd976d9a
...
...
@@ -2,7 +2,7 @@
Grouping around something to create a boundary or context, used for documenting,
accounting, planning. Extended from the default of
`Person | Organization`
"""
union
AccountingScope
=
Person
|
Organization
|
Community
|
Collection
union
AccountingScope
=
User
|
Organisation
|
Person
|
Organization
|
Community
|
Collection
"""
An action verb defining the kind of event, commitment, or intent.
...
...
lib/extensions/value_flows/util/graphql.ex
View file @
dd976d9a
...
...
@@ -25,8 +25,13 @@ defmodule ValueFlows.Util.GraphQL do
def
canonical_url_edge
(
obj
,
_
,
_
),
do
:
{
:ok
,
CommonsPub
.
ActivityPub
.
Utils
.
get_object_canonical_url
(
obj
)}
def
scope_edge
(%{
context_id:
id
},
page_opts
,
info
),
do
:
CommonsPub
.
Web
.
GraphQL
.
CommonResolver
.
context_edges
(%{
context_ids:
[
id
]},
page_opts
,
info
)
def
scope_edge
(
_
,
_
,
_
),
do
:
{
:ok
,
nil
}
def
fetch_provider_edge
(%{
provider_id:
id
},
_
,
info
)
when
not
is_nil
(
id
)
do
# CommonResolver.context_edge(%{context_id: id}, nil, info)
{
:ok
,
ValueFlows
.
Agent
.
Agents
.
agent
(
id
,
GraphQL
.
current_user
(
info
))}
end
...
...
@@ -35,7 +40,6 @@ defmodule ValueFlows.Util.GraphQL do
end
def
fetch_receiver_edge
(%{
receiver_id:
id
},
_
,
info
)
when
not
is_nil
(
id
)
do
# CommonResolver.context_edge(%{context_id: id}, nil, info)
{
:ok
,
ValueFlows
.
Agent
.
Agents
.
agent
(
id
,
GraphQL
.
current_user
(
info
))}
end
...
...
lib/mixology/common/common.ex
View file @
dd976d9a
...
...
@@ -14,7 +14,6 @@ defmodule CommonsPub.Common do
def
maybe_get
(%{}
=
map
,
key
,
fallback
),
do
:
Map
.
get
(
map
,
key
,
fallback
)
def
maybe_get
(
_
,
_
,
fallback
),
do
:
fallback
@doc
"conditionally update a map"
def
maybe_put
(
map
,
_key
,
nil
),
do
:
map
def
maybe_put
(
map
,
_key
,
""
),
do
:
map
...
...
@@ -22,6 +21,7 @@ defmodule CommonsPub.Common do
@doc
"Applies change_fn if the first parameter is not nil."
def
maybe
(
nil
,
_change_fn
),
do
:
nil
def
maybe
(
val
,
change_fn
)
do
change_fn
.
(
val
)
end
...
...
@@ -30,6 +30,7 @@ defmodule CommonsPub.Common do
def
maybe_ok_error
({
:ok
,
val
},
change_fn
)
do
{
:ok
,
change_fn
.
(
val
)}
end
def
maybe_ok_error
(
other
,
_change_fn
),
do
:
other
@doc
"Append an item to a list if it is not nil"
...
...
@@ -88,6 +89,18 @@ defmodule CommonsPub.Common do
end
end
def
attr_get_id
(
attrs
,
field_name
)
do
if
is_map
(
attrs
)
and
Map
.
has_key?
(
attrs
,
field_name
)
do
attr
=
Map
.
get
(
attrs
,
field_name
)
if
is_map
(
attr
)
and
Map
.
has_key?
(
attr
,
:id
)
do
attr
.
id
else
attr
end
end
end
def
maybe_str_to_atom
(
str
)
do
try
do
String
.
to_existing_atom
(
str
)
...
...
lib/mixology/graphql/phases/execution_resolution.ex
View file @
dd976d9a
...
...
@@ -31,7 +31,7 @@ defmodule CommonsPub.Web.GraphQL.Phase.ExecutionResolution do
defp
debug_exception
(
msg
,
exception
,
stacktrace
,
kind
)
do
debug_log
(
msg
,
exception
,
stacktrace
,
kind
)
if
CommonsPub
.
Config
.
get
(
:env
)
==
:dev
or
System
.
get_env
(
"SENTRY_ENV"
)
==
"next"
do
if
CommonsPub
.
Config
.
get
(
:env
)
==
:dev
or
CommonsPub
.
Config
.
get
(
:env
)
==
:test
or
System
.
get_env
(
"SENTRY_ENV"
)
==
"next"
do
{
:error
,
msg
<>
": "
<>
...
...
test/value_flows/agent/person/person_graphql_test.exs
View file @
dd976d9a
...
...
@@ -87,9 +87,7 @@ defmodule Valueflows.Agent.Person.GraphQLTest do
assert_intent
(
List
.
first
(
queried
[
"intents"
]))
assert_process
(
List
.
first
(
queried
[
"processes"
]))
assert_economic_event
(
List
.
first
(
queried
[
"economicEvents"
]))
# assert_economic_resource(List.first(queried["inventoriedEconomicResources"])) #TODO: not sure why nil
assert_economic_resource
(
List
.
first
(
queried
[
"inventoriedEconomicResources"
]))
assert_geolocation
(
queried
[
"primaryLocation"
])
end
end
...
...
test/value_flows/observation/event/events_graphql_test.exs
View file @
dd976d9a
...
...
@@ -129,7 +129,7 @@ defmodule ValueFlows.Observation.EconomicEvent.EventsGraphQLTest do
q
=
economic_event_query
(
fields:
[
in_scope_of:
[
:__typename
]])
conn
=
user_conn
(
user
)
assert
fetched
=
grumble_post_key
(
q
,
conn
,
:economic_event
,
%{
id:
event
.
id
})
assert
hd
(
fetched
[
"inScopeOf"
])[
"__typename"
]
==
"
User
"
assert
hd
(
fetched
[
"inScopeOf"
])[
"__typename"
]
==
"
Person
"
end
end
...
...
@@ -280,7 +280,7 @@ defmodule ValueFlows.Observation.EconomicEvent.EventsGraphQLTest do
assert
event
=
grumble_post_key
(
q
,
conn
,
:create_economic_event
,
vars
)[
"economicEvent"
]
assert_economic_event
(
event
)
assert
hd
(
event
[
"inScopeOf"
])[
"__typename"
]
==
"
User
"
assert
hd
(
event
[
"inScopeOf"
])[
"__typename"
]
==
"
Person
"
end
test
"create an economic event with an input and an output"
do
...
...
test/value_flows/planning/intent/intent_graphql_test.exs
View file @
dd976d9a
...
...
@@ -16,7 +16,7 @@ defmodule ValueFlows.Planning.Intent.GraphQLTest do
import
ValueFlows
.
Test
.
Faking
alias
ValueFlows
.
Planning
.
Intent
.
Intents
@debug
fals
e
@debug
tru
e
@schema
CommonsPub
.
Web
.
GraphQL
.
Schema
describe
"intent"
do
...
...
@@ -39,15 +39,19 @@ defmodule ValueFlows.Planning.Intent.GraphQLTest do
parent
=
fake_user!
()
intent
=
fake_intent!
(
user
,
%{
provider:
user
.
id
,
at_location:
location
,
resource_quantity:
measure
(%{
unit_id:
unit
.
id
}),
effort_quantity:
measure
(%{
unit_id:
unit
.
id
}),
available_quantity:
measure
(%{
unit_id:
unit
.
id
}),
in_scope_of:
[
parent
.
id
]
})
IO
.
inspect
(
intent:
intent
)
proposal
=
fake_proposal!
(
user
)
some
(
5
,
fn
->
fake_proposed_intent!
(
proposal
,
intent
)
end
)
fake_proposed_intent!
(
proposal
,
intent
)
assert
intent_queried
=
CommonsPub
.
Web
.
GraphQL
.
QueryHelper
.
run_query_id
(
...
...
@@ -60,6 +64,13 @@ defmodule ValueFlows.Planning.Intent.GraphQLTest do
)
assert_intent
(
intent_queried
)
assert_proposal
(
hd
(
intent_queried
[
"publishedIn"
])[
"publishedIn"
])
assert_geolocation
(
intent_queried
[
"atLocation"
])
assert_agent
(
intent_queried
[
"provider"
])
assert_measure
(
intent_queried
[
"resourceQuantity"
])
assert_measure
(
intent_queried
[
"availableQuantity"
])
assert_measure
(
intent_queried
[
"effortQuantity"
])
assert
hd
(
intent_queried
[
"inScopeOf"
])[
"__typename"
]
==
"Person"
end
test
"fails for deleted intent"
do
...
...
@@ -118,7 +129,7 @@ defmodule ValueFlows.Planning.Intent.GraphQLTest do
q
=
intent_query
(
fields:
[
in_scope_of:
[
:__typename
]])
conn
=
user_conn
(
user
)
assert
intent
=
grumble_post_key
(
q
,
conn
,
:intent
,
%{
id:
intent
.
id
})
assert
hd
(
intent
[
"inScopeOf"
])[
"__typename"
]
==
"
User
"
assert
hd
(
intent
[
"inScopeOf"
])[
"__typename"
]
==
"
Person
"
end
end
...
...
@@ -211,7 +222,7 @@ defmodule ValueFlows.Planning.Intent.GraphQLTest do
assert
intent
=
grumble_post_key
(
q
,
conn
,
:create_intent
,
vars
)[
"intent"
]
assert_intent
(
intent
)
assert
[
context
]
=
intent
[
"inScopeOf"
]
assert
context
[
"__typename"
]
==
"
User
"
assert
context
[
"__typename"
]
==
"
Person
"
end
test
"creates a new intent with a location"
do
...
...
@@ -372,7 +383,7 @@ defmodule ValueFlows.Planning.Intent.GraphQLTest do
assert
resp
=
grumble_post_key
(
q
,
conn
,
:update_intent
,
vars
)[
"intent"
]
assert
[
context
]
=
resp
[
"inScopeOf"
]
assert
context
[
"__typename"
]
==
"
User
"
assert
context
[
"__typename"
]
==
"
Person
"
end
test
"updates an existing intent with a location"
do
...
...
test/value_flows/proposal/proposal_graphql_test.exs
View file @
dd976d9a
...
...
@@ -137,7 +137,7 @@ defmodule ValueFlows.Proposal.GraphQLTest do
q
=
proposal_query
(
fields:
[
in_scope_of:
[
:__typename
]])
conn
=
user_conn
(
user
)
assert
proposal
=
grumble_post_key
(
q
,
conn
,
:proposal
,
%{
id:
proposal
.
id
})
assert
hd
(
proposal
[
"inScopeOf"
])[
"__typename"
]
==
"
User
"
assert
hd
(
proposal
[
"inScopeOf"
])[
"__typename"
]
==
"
Person
"
end
end
...
...
@@ -175,7 +175,7 @@ defmodule ValueFlows.Proposal.GraphQLTest do
vars
=
%{
proposal:
proposal_input
(%{
"inScopeOf"
=>
[
parent
.
id
]})}
assert
proposal
=
grumble_post_key
(
q
,
conn
,
:create_proposal
,
vars
)[
"proposal"
]
assert_proposal_full
(
proposal
)
assert
hd
(
proposal
[
"inScopeOf"
])[
"__typename"
]
==
"
User
"
assert
hd
(
proposal
[
"inScopeOf"
])[
"__typename"
]
==
"
Person
"
end
test
"creates a new proposal with an eligible location"
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment