Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
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
3cdd5ad9
Commit
3cdd5ad9
authored
Nov 11, 2020
by
Mayel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cleanup/pagination' into extension/valueflows
parents
a2a3aeda
8655f65e
Pipeline
#214853208
failed with stage
in 1 minute and 8 seconds
Changes
54
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
54 changed files
with
1097 additions
and
1220 deletions
+1097
-1220
lib/extensions/collections/collection.ex
lib/extensions/collections/collection.ex
+1
-1
lib/extensions/communities/communities.ex
lib/extensions/communities/communities.ex
+0
-2
lib/extensions/geolocations/geolocation.gql
lib/extensions/geolocations/geolocation.gql
+1
-1
lib/extensions/measurements/hydration.ex
lib/extensions/measurements/hydration.ex
+2
-2
lib/extensions/measurements/measure/graphql.ex
lib/extensions/measurements/measure/graphql.ex
+3
-3
lib/extensions/measurements/measure/queries.ex
lib/extensions/measurements/measure/queries.ex
+1
-24
lib/extensions/measurements/measurement.gql
lib/extensions/measurements/measurement.gql
+2
-2
lib/extensions/tags/simulate.ex
lib/extensions/tags/simulate.ex
+0
-1
lib/extensions/value_flows/claim/claim.ex
lib/extensions/value_flows/claim/claim.ex
+14
-8
lib/extensions/value_flows/claim/claims.ex
lib/extensions/value_flows/claim/claims.ex
+13
-14
lib/extensions/value_flows/claim/graphql.ex
lib/extensions/value_flows/claim/graphql.ex
+83
-3
lib/extensions/value_flows/claim/migrations.ex
lib/extensions/value_flows/claim/migrations.ex
+1
-1
lib/extensions/value_flows/claim/queries.ex
lib/extensions/value_flows/claim/queries.ex
+84
-0
lib/extensions/value_flows/hydration.ex
lib/extensions/value_flows/hydration.ex
+59
-1
lib/extensions/value_flows/knowledge/process_specification/graphql.ex
...ns/value_flows/knowledge/process_specification/graphql.ex
+1
-38
lib/extensions/value_flows/knowledge/process_specification/process_specs.ex
...ue_flows/knowledge/process_specification/process_specs.ex
+0
-14
lib/extensions/value_flows/knowledge/resource_specification/graphql.ex
...s/value_flows/knowledge/resource_specification/graphql.ex
+1
-24
lib/extensions/value_flows/observation/event/events.ex
lib/extensions/value_flows/observation/event/events.ex
+0
-20
lib/extensions/value_flows/observation/event/graphql.ex
lib/extensions/value_flows/observation/event/graphql.ex
+2
-54
lib/extensions/value_flows/observation/process/graphql.ex
lib/extensions/value_flows/observation/process/graphql.ex
+3
-11
lib/extensions/value_flows/observation/process/process.ex
lib/extensions/value_flows/observation/process/process.ex
+1
-19
lib/extensions/value_flows/observation/process/processes.ex
lib/extensions/value_flows/observation/process/processes.ex
+30
-50
lib/extensions/value_flows/observation/process/queries.ex
lib/extensions/value_flows/observation/process/queries.ex
+6
-14
lib/extensions/value_flows/observation/resource/graphql.ex
lib/extensions/value_flows/observation/resource/graphql.ex
+1
-1
lib/extensions/value_flows/observation/resource/queries.ex
lib/extensions/value_flows/observation/resource/queries.ex
+14
-1
lib/extensions/value_flows/observation/resource/resource.ex
lib/extensions/value_flows/observation/resource/resource.ex
+7
-53
lib/extensions/value_flows/observation/resource/resources.ex
lib/extensions/value_flows/observation/resource/resources.ex
+36
-143
lib/extensions/value_flows/planning/intent/intent.ex
lib/extensions/value_flows/planning/intent/intent.ex
+13
-66
lib/extensions/value_flows/planning/intent/intent_graphql.ex
lib/extensions/value_flows/planning/intent/intent_graphql.ex
+46
-93
lib/extensions/value_flows/planning/intent/intent_queries.ex
lib/extensions/value_flows/planning/intent/intent_queries.ex
+13
-32
lib/extensions/value_flows/planning/intent/intents.ex
lib/extensions/value_flows/planning/intent/intents.ex
+37
-119
lib/extensions/value_flows/proposal/proposal.ex
lib/extensions/value_flows/proposal/proposal.ex
+2
-36
lib/extensions/value_flows/proposal/proposal_graphql.ex
lib/extensions/value_flows/proposal/proposal_graphql.ex
+5
-72
lib/extensions/value_flows/proposal/proposal_queries.ex
lib/extensions/value_flows/proposal/proposal_queries.ex
+0
-91
lib/extensions/value_flows/proposal/proposals.ex
lib/extensions/value_flows/proposal/proposals.ex
+23
-67
lib/extensions/value_flows/proposal/proposed_intent_graphql.ex
...xtensions/value_flows/proposal/proposed_intent_graphql.ex
+0
-16
lib/extensions/value_flows/simulate.ex
lib/extensions/value_flows/simulate.ex
+24
-28
lib/extensions/value_flows/util/graphql.ex
lib/extensions/value_flows/util/graphql.ex
+18
-0
test/extensions/geolocations/graphql_test.exs
test/extensions/geolocations/graphql_test.exs
+17
-0
test/extensions/measurements/graphql_test.exs
test/extensions/measurements/graphql_test.exs
+18
-1
test/support/geolocation/faking.ex
test/support/geolocation/faking.ex
+25
-0
test/support/measurement/faking.ex
test/support/measurement/faking.ex
+26
-0
test/support/value_flows/faking.ex
test/support/value_flows/faking.ex
+83
-1
test/value_flows/agent/person/person_graphql_test.exs
test/value_flows/agent/person/person_graphql_test.exs
+7
-2
test/value_flows/claim/claim_graphql_test.exs
test/value_flows/claim/claim_graphql_test.exs
+116
-0
test/value_flows/claim/claims_test.exs
test/value_flows/claim/claims_test.exs
+156
-0
test/value_flows/observation/event/events_graphql_test.exs
test/value_flows/observation/event/events_graphql_test.exs
+4
-2
test/value_flows/observation/process/process_graphql_test.exs
.../value_flows/observation/process/process_graphql_test.exs
+5
-3
test/value_flows/observation/process/processes_test.exs
test/value_flows/observation/process/processes_test.exs
+6
-5
test/value_flows/observation/resource/resource_graphql_test.exs
...alue_flows/observation/resource/resource_graphql_test.exs
+5
-1
test/value_flows/planning/intent/intent_graphql_test.exs
test/value_flows/planning/intent/intent_graphql_test.exs
+43
-46
test/value_flows/planning/intent/intents_test.exs
test/value_flows/planning/intent/intents_test.exs
+15
-21
test/value_flows/proposal/proposal_graphql_test.exs
test/value_flows/proposal/proposal_graphql_test.exs
+20
-9
test/value_flows/proposal/proposals_test.exs
test/value_flows/proposal/proposals_test.exs
+4
-4
No files found.
lib/extensions/collections/collection.ex
View file @
3cdd5ad9
...
...
@@ -19,7 +19,7 @@ defmodule CommonsPub.Collections.Collection do
table_schema
"mn_collection"
do
# belongs_to(:actor, Character)
has_one
(
:character
,
C
ommonsPub
.
Characters
.
C
haracter
,
references:
:id
,
foreign_key:
:id
)
has_one
(
:character
,
Character
,
references:
:id
,
foreign_key:
:id
)
belongs_to
(
:creator
,
User
)
...
...
lib/extensions/communities/communities.ex
View file @
3cdd5ad9
...
...
@@ -24,8 +24,6 @@ defmodule CommonsPub.Communities do
alias
CommonsPub
.
Users
.
User
alias
CommonsPub
.
Workers
.
APPublishWorker
alias
CommonsPub
.
Utils
.
Web
.
CommonHelper
### Cursor generators
def
cursor
(
:followers
),
do
:
&
[
&1
.
follower_count
,
&1
.
id
]
...
...
lib/extensions/geolocations/geolocation.gql
View file @
3cdd5ad9
...
...
@@ -112,7 +112,7 @@ type GeolocationQuery {
limit
:
Int
before
:
[
Cursor
]
after
:
[
Cursor
]
):
[
SpatialThingsPage
!]
):
SpatialThingsPage
!
}
type
GeolocationMutation
{
...
...
lib/extensions/measurements/hydration.ex
View file @
3cdd5ad9
...
...
@@ -36,8 +36,8 @@ defmodule Measurement.Hydration do
unit:
[
resolve:
&
Measurement
.
Unit
.
GraphQL
.
unit
/
2
],
measures:
[
resolve:
&
Measurement
.
Measure
.
GraphQL
.
measures
/
2
measures
_pages
:
[
resolve:
&
Measurement
.
Measure
.
GraphQL
.
measures
_pages
/
2
],
# all_measures: [
# resolve: &Measurement.Measure.GraphQL.all_measures/2
...
...
lib/extensions/measurements/measure/graphql.ex
View file @
3cdd5ad9
...
...
@@ -29,7 +29,7 @@ defmodule Measurement.Measure.GraphQL do
})
end
def
measures
(
page_opts
,
info
)
do
def
measures
_pages
(
page_opts
,
info
)
do
ResolveRootPage
.
run
(%
ResolveRootPage
{
module:
__MODULE__
,
fetcher:
:fetch_measures
,
...
...
@@ -53,10 +53,10 @@ defmodule Measurement.Measure.GraphQL do
FetchPage
.
run
(%
FetchPage
{
queries:
Measurement
.
Measure
.
Queries
,
query:
Measurement
.
Measure
,
# cursor_fn: measures.cursor(:followers)
,
cursor_fn:
&
&1
.
id
,
page_opts:
page_opts
,
base_filters:
[
user:
GraphQL
.
current_user
(
info
)],
data_filters:
[
:d
a
fault
]
data_filters:
[
:d
e
fault
]
})
end
...
...
lib/extensions/measurements/measure/queries.ex
View file @
3cdd5ad9
...
...
@@ -85,6 +85,7 @@ defmodule Measurement.Measure.Queries do
## by field values
def
filter
(
q
,
{
:id
,
id
})
when
is_binary
(
id
)
do
where
(
q
,
[
measure:
c
],
c
.
id
==
^
id
)
end
...
...
@@ -120,30 +121,6 @@ defmodule Measurement.Measure.Queries do
select
(
q
,
[
measure:
c
],
{
field
(
c
,
^
key
),
count
(
c
.
id
)})
end
# pagination
def
filter
(
q
,
{
:limit
,
limit
})
do
limit
(
q
,
^
limit
)
end
def
filter
(
q
,
{
:paginate_id
,
%{
after
:
a
,
limit:
limit
}})
do
limit
=
limit
+
2
q
|>
where
([
measure:
c
],
c
.
id
>=
^
a
)
|>
limit
(
^
limit
)
end
def
filter
(
q
,
{
:paginate_id
,
%{
before:
b
,
limit:
limit
}})
do
q
|>
where
([
measure:
c
],
c
.
id
<=
^
b
)
|>
filter
(
limit:
limit
+
2
)
end
def
filter
(
q
,
{
:paginate_id
,
%{
limit:
limit
}})
do
filter
(
q
,
limit:
limit
+
1
)
end
# defp page(q, %{limit: limit}, _), do: filter(q, limit: limit + 1)
def
inc_quantity
(
id
,
amount
)
do
...
...
lib/extensions/measurements/measurement.gql
View file @
3cdd5ad9
...
...
@@ -140,11 +140,11 @@ type MeasuresPage {
type
MeasurementQuery
{
unit
(
id
:
ID
):
Unit
units
(
start
:
ID
,
limit
:
Int
):
[
Unit
!]
unitsPages
(
limit
:
Int
,
before
:
[
Cursor
],
after
:
[
Cursor
]):
[
UnitsPage
!]
unitsPages
(
limit
:
Int
,
before
:
[
Cursor
],
after
:
[
Cursor
]):
UnitsPage
!
measure
(
id
:
ID
):
Measure
measures
(
start
:
ID
,
limit
:
Int
):
[
Measure
!]
measuresPages
(
limit
:
Int
,
before
:
[
Cursor
],
after
:
[
Cursor
]):
[
MeasuresPage
!]
measuresPages
(
limit
:
Int
,
before
:
[
Cursor
],
after
:
[
Cursor
]):
MeasuresPage
!
}
type
MeasurementMutation
{
...
...
lib/extensions/tags/simulate.ex
View file @
3cdd5ad9
...
...
@@ -3,7 +3,6 @@ defmodule CommonsPub.Tag.Simulate do
@moduledoc
false
import
CommonsPub
.
Utils
.
Simulation
import
CommonsPub
.
Utils
.
Trendy
alias
CommonsPub
.
Tag
.
Categories
...
...
lib/extensions/value_flows/claim/claim.ex
View file @
3cdd5ad9
...
...
@@ -63,14 +63,26 @@ defmodule ValueFlows.Claim do
receiver_id:
receiver
.
id
,
is_public:
true
)
|>
change_measures
(
attrs
)
|>
common_changeset
()
|>
common_changeset
(
attrs
)
end
def
update_changeset
(%
__MODULE__
{}
=
claim
,
attrs
)
do
claim
|>
Changeset
.
cast
(
attrs
,
@cast
)
|>
common_changeset
(
attrs
)
end
def
validate_required
(
changeset
)
do
Changeset
.
validate_required
(
changeset
,
@required
)
end
defp
common_changeset
(
changeset
,
attrs
)
do
changeset
|>
change_measures
(
attrs
)
|>
change_public
()
|>
change_disabled
()
end
def
change_measures
(
changeset
,
%{}
=
attrs
)
do
measures
=
Map
.
take
(
attrs
,
measure_fields
())
...
...
@@ -79,11 +91,5 @@ defmodule ValueFlows.Claim do
end
)
end
defp
common_changeset
(
changeset
)
do
changeset
|>
change_public
()
|>
change_disabled
()
end
def
measure_fields
,
do
:
[
:resource_quantity
,
:effort_quantity
]
end
lib/extensions/value_flows/claim/claims.ex
View file @
3cdd5ad9
...
...
@@ -15,19 +15,11 @@ defmodule ValueFlows.Claim.Claims do
def
many
(
filters
\\
[]),
do
:
{
:ok
,
Repo
.
all
(
Queries
.
query
(
Claim
,
filters
))}
def
preload_all
(%
Claim
{}
=
claim
)
do
Repo
.
preload
(
claim
,
[
:creator
,
:provider
,
:receiver
,
:context
,
:resource_conforms_to
,
:resource_quantity
,
:effort_quantity
,
:triggered_by
,
])
# shouldn't fail
{
:ok
,
claim
}
=
one
(
id:
claim
.
id
,
preload:
:all
)
claim
end
# TODO: change attributes and then pass to changeset, use preload for rest
def
create
(%
User
{}
=
creator
,
%{
id:
_
}
=
provider
,
%{
id:
_
}
=
receiver
,
%{}
=
attrs
)
do
Repo
.
transact_with
(
fn
->
attrs
=
prepare_attrs
(
attrs
)
...
...
@@ -42,12 +34,19 @@ defmodule ValueFlows.Claim.Claims do
end
)
end
def
update
(%
Claim
{}
=
claim
,
%{}
=
_attrs
)
do
{
:ok
,
claim
}
def
update
(%
Claim
{}
=
claim
,
%{}
=
attrs
)
do
Repo
.
transact_with
(
fn
->
attrs
=
prepare_attrs
(
attrs
)
claim
|>
Claim
.
update_changeset
(
attrs
)
|>
Repo
.
update
()
|>
CommonsPub
.
Common
.
maybe_ok_error
(
&
preload_all
/
1
)
end
)
end
def
soft_delete
(%
Claim
{}
=
claim
)
do
{
:ok
,
claim
}
CommonsPub
.
Common
.
Deletion
.
soft_delete
(
claim
)
end
defp
prepare_attrs
(
attrs
)
do
...
...
lib/extensions/value_flows/claim/graphql.ex
View file @
3cdd5ad9
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Claim
.
GraphQL
do
# alias CommonsPub.Web.GraphQL.{CommonResolver}
require
Logger
# use Absinthe.Schema.Notation
# import_sdl path: "lib/value_flows/graphql/schemas/claim.gql"
alias
CommonsPub
.
{
GraphQL
,
Repo
}
alias
CommonsPub
.
Meta
.
Pointers
alias
CommonsPub
.
GraphQL
.
{
FetchPage
,
ResolveField
,
ResolveRootPage
}
alias
ValueFlows
.
Claim
.
Claims
def
claim
(%{
id:
id
},
info
)
do
ResolveField
.
run
(%
ResolveField
{
module:
__MODULE__
,
fetcher:
:fetch_claim
,
context:
id
,
info:
info
})
end
def
claims
(
page_opts
,
info
)
do
ResolveRootPage
.
run
(%
ResolveRootPage
{
module:
__MODULE__
,
fetcher:
:fetch_claims
,
page_opts:
page_opts
,
info:
info
,
cursor_validators:
[
&
(
is_integer
(
&1
)
and
&1
>=
0
),
&
Ecto
.
ULID
.
cast
/
1
]
})
end
def
fetch_claim
(
_info
,
id
)
do
Claims
.
one
([
:default
,
id:
id
])
end
def
fetch_events
(
page_opts
,
info
)
do
FetchPage
.
run
(%
FetchPage
{
queries:
ValueFlows
.
Claim
.
Queries
,
query:
ValueFlows
.
Claim
,
page_opts:
page_opts
,
base_filters:
[
:default
,
user:
GraphQL
.
current_user
(
info
)
]
})
end
def
fetch_resource_conforms_to_edge
(%{
resource_conforms_to_id:
id
}
=
thing
,
_
,
_
)
when
is_binary
(
id
)
do
thing
=
Repo
.
preload
(
thing
,
:resource_conforms_to
)
{
:ok
,
Map
.
get
(
thing
,
:resource_conforms_to
)}
end
def
fetch_resource_conforms_to_edge
(
_
,
_
,
_
)
do
{
:ok
,
nil
}
end
def
fetch_triggered_by_edge
(%{
triggered_by_id:
id
}
=
thing
,
_
,
_
)
when
is_binary
(
id
)
do
thing
=
Repo
.
preload
(
thing
,
:triggered_by
)
{
:ok
,
Map
.
get
(
thing
,
:triggered_by
)}
end
def
fetch_triggered_by_edge
(
_
,
_
,
_
)
do
{
:ok
,
nil
}
end
def
create_claim
(%{
claim:
%{
provider:
provider_id
,
receiver:
receiver_id
}
=
attrs
},
info
)
do
with
{
:ok
,
user
}
<-
GraphQL
.
current_user_or_not_logged_in
(
info
),
{
:ok
,
provider
}
<-
Pointers
.
one
(
id:
provider_id
),
{
:ok
,
receiver
}
<-
Pointers
.
one
(
id:
receiver_id
),
{
:ok
,
claim
}
<-
Claims
.
create
(
user
,
provider
,
receiver
,
attrs
)
do
{
:ok
,
%{
claim:
claim
}}
end
end
def
update_claim
(%{
claim:
%{
id:
id
}
=
attrs
},
info
)
do
with
{
:ok
,
_user
}
<-
GraphQL
.
current_user_or_not_logged_in
(
info
),
{
:ok
,
claim
}
<-
claim
(%{
id:
id
},
info
),
{
:ok
,
claim
}
<-
Claims
.
update
(
claim
,
attrs
)
do
{
:ok
,
%{
claim:
claim
}}
end
end
def
delete_claim
(%{
id:
id
},
info
)
do
with
{
:ok
,
_user
}
<-
GraphQL
.
current_user_or_not_logged_in
(
info
),
{
:ok
,
claim
}
<-
claim
(%{
id:
id
},
info
),
{
:ok
,
_
}
<-
Claims
.
soft_delete
(
claim
)
do
{
:ok
,
true
}
end
end
end
lib/extensions/value_flows/claim/migrations.ex
View file @
3cdd5ad9
...
...
@@ -10,7 +10,7 @@ defmodule ValueFlows.Claim.Migrations do
def
up
do
create_pointable_table
(
ValueFlows
.
Claim
)
do
add
(
:note
,
:text
)
add
(
:agreed_in
,
:
string
)
add
(
:agreed_in
,
:
text
)
add
(
:action_id
,
:string
)
add
(
:finished
,
:boolean
)
...
...
lib/extensions/value_flows/claim/queries.ex
View file @
3cdd5ad9
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Claim
.
Queries
do
import
CommonsPub
.
Common
.
Query
,
only:
[
match_admin:
0
]
import
Ecto
.
Query
alias
CommonsPub
.
Follows
.
Follow
alias
CommonsPub
.
Users
.
User
alias
ValueFlows
.
Claim
def
query
(
Claim
)
do
...
...
@@ -27,6 +30,13 @@ defmodule ValueFlows.Claim.Queries do
join
(
q
,
jq
,
[
claim:
c
],
c2
in
assoc
(
c
,
:context
),
as:
:context
)
end
def
join_to
(
q
,
{
:follow
,
follower_id
},
jq
)
do
join
(
q
,
jq
,
[
claim:
c
],
f
in
Follow
,
as:
:follow
,
on:
c
.
id
==
f
.
context_id
and
f
.
creator_id
==
^
follower_id
)
end
def
filter
(
q
,
filters
)
when
is_list
(
filters
)
do
Enum
.
reduce
(
filters
,
q
,
&
filter
(
&2
,
&1
))
end
...
...
@@ -34,6 +44,8 @@ defmodule ValueFlows.Claim.Queries do
def
filter
(
q
,
{
:join
,
{
join
,
qual
}}),
do
:
join_to
(
q
,
join
,
qual
)
def
filter
(
q
,
{
:join
,
join
}),
do
:
join_to
(
q
,
join
)
## by status
def
filter
(
q
,
:default
)
do
filter
(
q
,
[
:deleted
])
end
...
...
@@ -42,6 +54,31 @@ defmodule ValueFlows.Claim.Queries do
where
(
q
,
[
claim:
c
],
is_nil
(
c
.
deleted_at
))
end
def
filter
(
q
,
:disabled
)
do
where
(
q
,
[
claim:
c
],
is_nil
(
c
.
disabled_at
))
end
def
filter
(
q
,
:private
)
do
where
(
q
,
[
claim:
c
],
not
is_nil
(
c
.
published_at
))
end
## by user
def
filter
(
q
,
{
:creator
,
match_admin
()}),
do
:
q
def
filter
(
q
,
{
:creator
,
nil
})
do
filter
(
q
,
~w(disabled private)a
)
end
def
filter
(
q
,
{
:creator
,
%
User
{
id:
id
}})
do
q
|>
join_to
(
follow:
id
)
|>
where
([
claim:
c
,
follow:
f
],
not
is_nil
(
c
.
published_at
)
or
not
is_nil
(
f
.
id
))
|>
filter
(
~w(disabled)a
)
end
## by field values
def
filter
(
q
,
{
:id
,
id
})
when
is_binary
(
id
)
do
where
(
q
,
[
claim:
c
],
c
.
id
==
^
id
)
end
...
...
@@ -49,4 +86,51 @@ defmodule ValueFlows.Claim.Queries do
def
filter
(
q
,
{
:id
,
ids
})
when
is_list
(
ids
)
do
where
(
q
,
[
claim:
c
],
c
.
id
in
^
ids
)
end
def
filter
(
q
,
{
:provider_id
,
id
})
when
is_binary
(
id
)
do
where
(
q
,
[
claim:
c
],
c
.
provider_id
==
^
id
)
end
def
filter
(
q
,
{
:provider_id
,
ids
})
when
is_list
(
ids
)
do
where
(
q
,
[
claim:
c
],
c
.
provider_id
in
^
ids
)
end
def
filter
(
q
,
{
:receiver_id
,
id
})
when
is_binary
(
id
)
do
where
(
q
,
[
claim:
c
],
c
.
receiver_id
==
^
id
)
end
def
filter
(
q
,
{
:receiver_id
,
ids
})
when
is_list
(
ids
)
do
where
(
q
,
[
claim:
c
],
c
.
receiver_id
in
^
ids
)
end
def
filter
(
q
,
{
:context_id
,
id
})
when
is_binary
(
id
)
do
where
(
q
,
[
claim:
c
],
c
.
context_id
==
^
id
)
end
def
filter
(
q
,
{
:context_id
,
ids
})
when
is_list
(
ids
)
do
where
(
q
,
[
claim:
c
],
c
.
context_id
in
^
ids
)
end
def
filter
(
q
,
{
:action_id
,
ids
})
when
is_list
(
ids
)
do
where
(
q
,
[
claim:
c
],
c
.
action_id
in
^
ids
)
end
def
filter
(
q
,
{
:action_id
,
id
})
when
is_binary
(
id
)
do
where
(
q
,
[
claim:
c
],
c
.
action_id
==
^
id
)
end
## preloading
def
filter
(
q
,
{
:preload
,
:all
})
do
preload
(
q
,
[
:creator
,
:provider
,
:receiver
,
:resource_conforms_to
,
:resource_quantity
,
:effort_quantity
,
:context
,
:triggered_by
,
])
end
end
lib/extensions/value_flows/hydration.ex
View file @
3cdd5ad9
...
...
@@ -119,7 +119,48 @@ defmodule ValueFlows.Hydration do
],
published_in:
[
resolve:
&
ValueFlows
.
Proposal
.
ProposedIntentGraphQL
.
published_in_edge
/
3
]
],
resource_conforms_to:
[
resolve:
&
ValueFlows
.
Planning
.
Intent
.
GraphQL
.
fetch_resource_conforms_to_edge
/
3
],
resource_inventoried_as:
[
resolve:
&
ValueFlows
.
Planning
.
Intent
.
GraphQL
.
fetch_resource_inventoried_as_edge
/
3
],
input_of:
[
resolve:
&
ValueFlows
.
Planning
.
Intent
.
GraphQL
.
fetch_input_of_edge
/
3
],
output_of:
[
resolve:
&
ValueFlows
.
Planning
.
Intent
.
GraphQL
.
fetch_output_of_edge
/
3
],
},
claim:
%{
action:
[
resolve:
&
ValueFlows
.
Knowledge
.
Action
.
GraphQL
.
action_edge
/
3
,
],
provider:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
fetch_provider_edge
/
3
],
receiver:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
fetch_receiver_edge
/
3
],
resource_quantity:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
resource_quantity_edge
/
3
],
effort_quantity:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
effort_quantity_edge
/
3
],
resource_conforms_to:
[
resolve:
&
ValueFlows
.
Claim
.
GraphQL
.
fetch_resource_conforms_to_edge
/
3
,
],
triggered_by:
[
resolve:
&
ValueFlows
.
Claim
.
GraphQL
.
fetch_triggered_by_edge
/
3
,
],
in_scope_of:
[
resolve:
&
CommonResolver
.
context_edge
/
3
,
],
creator:
[
resolve:
&
UsersResolver
.
creator_edge
/
3
],
},
economic_event:
%{
canonical_url:
[
...
...
@@ -272,6 +313,14 @@ defmodule ValueFlows.Hydration do
resolve:
&
ValueFlows
.
Agent
.
GraphQL
.
organizations
/
2
],
# Claim
claim:
[
resolve:
&
ValueFlows
.
Claim
.
GraphQL
.
claim
/
2
,
],
claims:
[
resolve:
&
ValueFlows
.
Claim
.
GraphQL
.
claims
/
2
,
],
# Knowledge
action:
[
resolve:
&
ValueFlows
.
Knowledge
.
Action
.
GraphQL
.
action
/
2
...
...
@@ -366,6 +415,9 @@ defmodule ValueFlows.Hydration do
# start Mutation resolvers
value_flows_mutation:
%{
create_claim:
[
resolve:
&
ValueFlows
.
Claim
.
GraphQL
.
create_claim
/
2
,
],
create_intent:
[
resolve:
&
ValueFlows
.
Planning
.
Intent
.
GraphQL
.
create_intent
/
2
],
...
...
@@ -387,6 +439,9 @@ defmodule ValueFlows.Hydration do
# create_action: [
# resolve: &ValueFlows.Knowledge.Action.GraphQL.create_action/2
# ],
update_claim:
[
resolve:
&
ValueFlows
.
Claim
.
GraphQL
.
update_claim
/
2
,
],
update_intent:
[
resolve:
&
ValueFlows
.
Planning
.
Intent
.
GraphQL
.
update_intent
/
2
],
...
...
@@ -402,6 +457,9 @@ defmodule ValueFlows.Hydration do
update_process:
[
resolve:
&
ValueFlows
.
Observation
.
Process
.
GraphQL
.
update_process
/
2
],
delete_claim:
[
resolve:
&
ValueFlows
.
Claim
.
GraphQL
.
delete_claim
/
2
,
],
delete_intent:
[
resolve:
&
ValueFlows
.
Planning
.
Intent
.
GraphQL
.
delete_intent
/
2
],
...
...
lib/extensions/value_flows/knowledge/process_specification/graphql.ex
View file @
3cdd5ad9
...
...
@@ -3,46 +3,20 @@ defmodule ValueFlows.Knowledge.ProcessSpecification.GraphQL do
require
Logger
alias
CommonsPub
.
{
# Activities,
# Communities,
GraphQL
,
Repo
# User
}
alias
CommonsPub
.
{
GraphQL
,
Repo
}
alias
CommonsPub
.
GraphQL
.
{
ResolveField
,
# ResolveFields,
# ResolvePage,
ResolvePages
,
ResolveRootPage
,
FetchPage
# FetchPages,
# CommonResolver
}
# alias CommonsPub.Resources.Resource
# alias CommonsPub.Common.Enums
alias
CommonsPub
.
Meta
.
Pointers
# alias CommonsPub.Communities.Community
# alias CommonsPub.Web.GraphQL.CommunitiesResolver
alias
ValueFlows
.
Knowledge
.
ProcessSpecification
alias
ValueFlows
.
Knowledge
.
ProcessSpecification
.
ProcessSpecifications
alias
ValueFlows
.
Knowledge
.
ProcessSpecification
.
Queries
# alias ValueFlows.Knowledge.Action.Actions
# alias CommonsPub.Web.GraphQL.CommonResolver
alias
CommonsPub
.
Web
.
GraphQL
.
UploadResolver
# SDL schema import
# use Absinthe.Schema.Notation