Commit 0cea1d47 authored by Antonis Kalou's avatar Antonis Kalou

Remove unused aliases, fix small syntax issues

parent 27543490
......@@ -19,7 +19,7 @@ defmodule CommonsPub.Collections.Collection do
table_schema "mn_collection" do
# belongs_to(:actor, Character)
has_one(:character, CommonsPub.Characters.Character, references: :id, foreign_key: :id)
has_one(:character, Character, references: :id, foreign_key: :id)
belongs_to(:creator, User)
......
......@@ -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]
......
......@@ -3,7 +3,6 @@ defmodule CommonsPub.Tag.Simulate do
@moduledoc false
import CommonsPub.Utils.Simulation
import CommonsPub.Utils.Trendy
alias CommonsPub.Tag.Categories
......
......@@ -26,7 +26,7 @@ defmodule ValueFlows.Claim.GraphQL do
})
end
def fetch_claim(info, id) do
def fetch_claim(_info, id) do
Claims.one([:default, id: id])
end
......
......@@ -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
# import_sdl path: "lib/value_flows/graphql/schemas/planning.gql"
# TODO: put in config
# @tags_seperator " "
## resolvers
def simulate(%{id: _id}, _) do
......@@ -78,15 +52,9 @@ defmodule ValueFlows.Knowledge.ProcessSpecification.GraphQL do
end
def process_specs_filtered(page_opts, _) do
IO.inspect(process_specs_filtered: page_opts)
process_specs_filter(page_opts, [])
end
# def process_specs_filtered(page_opts, _) do
# IO.inspect(unhandled_filtering: page_opts)
# all_process_specs(page_opts, nil)
# end
# TODO: support several filters combined, plus pagination on filtered queries
defp process_specs_filter(%{in_scope_of: context_id} = page_opts, filters_acc) do
......@@ -101,17 +69,12 @@ defmodule ValueFlows.Knowledge.ProcessSpecification.GraphQL do
_,
filters_acc
) do
# IO.inspect(filters_query: filters_acc)
# finally, if there's no more known params to acumulate, query with the filters
ProcessSpecifications.many(filters_acc)
end
defp process_specs_filter_next(param_remove, filter_add, page_opts, filters_acc)
when is_list(param_remove) and is_list(filter_add) do
IO.inspect(process_specs_filter_next: param_remove)
IO.inspect(process_specs_filter_add: filter_add)
process_specs_filter(Map.drop(page_opts, param_remove), filters_acc ++ filter_add)
end
......
......@@ -113,18 +113,6 @@ defmodule ValueFlows.Knowledge.ProcessSpecification.ProcessSpecifications do
end
end
defp publish(creator, context, process_spec, activity, :created) do
feeds = [
context.outbox_id,
CommonsPub.Feeds.outbox_id(creator),
Feeds.instance_outbox_id()
]
with :ok <- FeedActivities.publish(activity, feeds) do
ap_publish("create", process_spec.id, creator.id)
end
end
defp publish(process_spec, :updated) do
# TODO: wrong if edited by admin
ap_publish("update", process_spec.id, process_spec.creator_id)
......@@ -145,8 +133,6 @@ defmodule ValueFlows.Knowledge.ProcessSpecification.ProcessSpecifications do
:ok
end
defp ap_publish(_, _, _), do: :ok
# TODO: take the user who is performing the update
# @spec update(%ProcessSpecification{}, attrs :: map) :: {:ok, ProcessSpecification.t()} | {:error, Changeset.t()}
def update(%ProcessSpecification{} = process_spec, attrs) do
......
......@@ -4,43 +4,20 @@ defmodule ValueFlows.Knowledge.ResourceSpecification.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.ResourceSpecification
alias ValueFlows.Knowledge.ResourceSpecification.ResourceSpecifications
alias ValueFlows.Knowledge.ResourceSpecification.Queries
# alias ValueFlows.Knowledge.Action.Actions
# alias CommonsPub.Web.GraphQL.CommonResolver
alias CommonsPub.Web.GraphQL.UploadResolver
# SDL schema import
# use Absinthe.Schema.Notation
# import_sdl path: "lib/value_flows/graphql/schemas/planning.gql"
## resolvers
def simulate(%{id: _id}, _) do
......
......@@ -7,12 +7,6 @@ defmodule ValueFlows.Observation.EconomicEvent.EconomicEvents do
alias CommonsPub.Contexts
alias CommonsPub.Feeds.FeedActivities
alias CommonsPub.Users.User
alias CommonsPub.Meta.Pointers
alias Geolocation.Geolocations
alias ValueFlows.Knowledge.Action.Actions
alias ValueFlows.Knowledge.ResourceSpecification.ResourceSpecifications
alias ValueFlows.Observation.EconomicEvent
alias ValueFlows.Observation.EconomicResource.EconomicResources
......@@ -421,18 +415,6 @@ defmodule ValueFlows.Observation.EconomicEvent.EconomicEvents do
end
end
defp publish(creator, context, event, activity, :created) do
feeds = [
context.outbox_id,
CommonsPub.Feeds.outbox_id(creator),
Feeds.instance_outbox_id()
]
with :ok <- FeedActivities.publish(activity, feeds) do
ap_publish("create", event.id, creator.id)
end
end
defp publish(event, :updated) do
# TODO: wrong if edited by admin
ap_publish("update", event.id, event.creator_id)
......@@ -453,8 +435,6 @@ defmodule ValueFlows.Observation.EconomicEvent.EconomicEvents do
:ok
end
defp ap_publish(_, _, _), do: :ok
def indexing_object_format(obj) do
%{
"index_type" => "EconomicEvent",
......
......@@ -87,7 +87,8 @@ defmodule ValueFlows.Observation.Process.Processes do
def trace(process), do: inputs(process)
def inputs(%{id: id}, action_id \\ nil) when not is_nil(action_id) do
def inputs(attrs, action_id \\ nil)
def inputs(%{id: id}, action_id) when not is_nil(action_id) do
EconomicEvents.many([:default, input_of_id: id, action_id: action_id])
end
......@@ -95,7 +96,12 @@ defmodule ValueFlows.Observation.Process.Processes do
EconomicEvents.many([:default, input_of_id: id])
end
def outputs(%{id: id}, action_id \\ nil) when not is_nil(action_id) do
def inputs(_, _) do
{:ok, nil}
end
def outputs(attrs, action_id \\ nil)
def outputs(%{id: id}, action_id) when not is_nil(action_id) do
EconomicEvents.many([:default, output_of_id: id, action_id: action_id])
end
......@@ -143,18 +149,6 @@ defmodule ValueFlows.Observation.Process.Processes do
end
end
defp publish(creator, context, process, activity, :created) do
feeds = [
context.outbox_id,
CommonsPub.Feeds.outbox_id(creator),
Feeds.instance_outbox_id()
]
with :ok <- FeedActivities.publish(activity, feeds) do
ap_publish("create", process.id, creator.id)
end
end
defp publish(process, :updated) do
# TODO: wrong if edited by admin
ap_publish("update", process.id, process.creator_id)
......@@ -175,8 +169,6 @@ defmodule ValueFlows.Observation.Process.Processes do
:ok
end
defp ap_publish(_, _, _), do: :ok
# TODO: take the user who is performing the update
# @spec update(%Process{}, attrs :: map) :: {:ok, Process.t()} | {:error, Changeset.t()}
def update(%Process{} = process, attrs) do
......
......@@ -46,7 +46,7 @@ defmodule ValueFlows.Observation.EconomicResource.Queries do
join(q, :inner, [resource: r],
e in EconomicEvent,
as: :event,
on: e.resource_inventoried_as_id == r.id and e.output_of_id == ^output_of_id,
on: e.resource_inventoried_as_id == r.id and e.output_of_id == ^output_of_id
)
end
......
......@@ -14,7 +14,7 @@ defmodule ValueFlows.Observation.EconomicResource do
alias ValueFlows.Knowledge.Action
alias ValueFlows.Knowledge.ResourceSpecification
alias ValueFlows.Knowledge.ProcessSpecification
# alias ValueFlows.Knowledge.ProcessSpecification
alias ValueFlows.Observation.EconomicResource
......
......@@ -7,16 +7,10 @@ defmodule ValueFlows.Observation.EconomicResource.EconomicResources do
alias CommonsPub.Contexts
alias CommonsPub.Feeds.FeedActivities
alias CommonsPub.Users.User
alias CommonsPub.Meta.Pointers
alias Geolocation.Geolocations
alias Measurement.Unit.Units
alias ValueFlows.Knowledge.ResourceSpecification.ResourceSpecifications
alias ValueFlows.Knowledge.ProcessSpecification.ProcessSpecifications
alias ValueFlows.Observation.EconomicResource
alias ValueFlows.Observation.EconomicResource.Queries
alias ValueFlows.Observation.EconomicEvent.EconomicEvents
alias ValueFlows.Knowledge.Action.Actions
def cursor(), do: &[&1.id]
def test_cursor(), do: &[&1["id"]]
......@@ -170,18 +164,6 @@ defmodule ValueFlows.Observation.EconomicResource.EconomicResources do
end
end
defp publish(creator, context, resource, activity, :created) do
feeds = [
context.outbox_id,
CommonsPub.Feeds.outbox_id(creator),
Feeds.instance_outbox_id()
]
with :ok <- FeedActivities.publish(activity, feeds) do
ap_publish("create", resource.id, creator.id)
end
end
defp publish(resource, :updated) do
# TODO: wrong if edited by admin
ap_publish("update", resource.id, resource.creator_id)
......@@ -202,8 +184,6 @@ defmodule ValueFlows.Observation.EconomicResource.EconomicResources do
:ok
end
defp ap_publish(_, _, _), do: :ok
def indexing_object_format(obj) do
# icon = CommonsPub.Uploads.remote_url_from_id(obj.icon_id)
image = CommonsPub.Uploads.remote_url_from_id(obj.image_id)
......
......@@ -14,12 +14,9 @@ defmodule ValueFlows.Planning.Intent.GraphQL do
FetchPage
}
alias CommonsPub.Meta.Pointers
alias ValueFlows.Planning.Intent
alias ValueFlows.Planning.Intent.Intents
alias ValueFlows.Planning.Intent.Queries
alias ValueFlows.Knowledge.Action.Actions
alias CommonsPub.Web.GraphQL.UploadResolver
## resolvers
......
......@@ -7,9 +7,7 @@ defmodule ValueFlows.Planning.Intent.Intents do
alias CommonsPub.Contexts
alias CommonsPub.Feeds.FeedActivities
alias CommonsPub.Users.User
alias CommonsPub.Meta.Pointers
alias Geolocation.Geolocations
alias ValueFlows.Knowledge.Action.Actions
alias ValueFlows.Planning.Intent
alias ValueFlows.Planning.Intent.Queries
......@@ -126,18 +124,6 @@ defmodule ValueFlows.Planning.Intent.Intents do
end
end
defp publish(creator, context, intent, activity, :created) do
feeds = [
context.outbox_id,
CommonsPub.Feeds.outbox_id(creator),
Feeds.instance_outbox_id()
]
with :ok <- FeedActivities.publish(activity, feeds) do
ap_publish("create", intent.id, creator.id)
end
end
defp publish(intent, :updated) do
# TODO: wrong if edited by admin
ap_publish("update", intent.id, intent.creator_id)
......@@ -158,8 +144,6 @@ defmodule ValueFlows.Planning.Intent.Intents do
:ok
end
defp ap_publish(_, _, _), do: :ok
# TODO: take the user who is performing the update
# @spec update(%Intent{}, attrs :: map) :: {:ok, Intent.t()} | {:error, Changeset.t()}
def update(%Intent{} = intent, attrs) do
......
......@@ -13,8 +13,6 @@ defmodule ValueFlows.Proposal.GraphQL do
FetchPage
}
alias CommonsPub.Meta.Pointers
alias ValueFlows.Proposal.Proposals
## resolvers
......
......@@ -8,8 +8,6 @@ defmodule ValueFlows.Proposal.Proposals do
alias CommonsPub.Feeds.FeedActivities
alias CommonsPub.Users.User
alias Geolocation.Geolocations
# alias Measurement.Measure
alias ValueFlows.Proposal
alias ValueFlows.Proposal
......@@ -23,9 +21,6 @@ defmodule ValueFlows.Proposal.Proposals do
alias ValueFlows.Planning.Intent
# use Assertions.AbsintheCase, async: true, schema: ValueFlows.Schema
# import Assertions.Absinthe, only: [document_for: 4]
@schema CommonsPub.Web.GraphQL.Schema
def cursor(), do: &[&1.id]
......@@ -153,18 +148,6 @@ defmodule ValueFlows.Proposal.Proposals do
end
end
defp publish(creator, context, proposal, activity, :created) do
feeds = [
context.outbox_id,
CommonsPub.Feeds.outbox_id(creator),
Feeds.instance_outbox_id()
]
with :ok <- FeedActivities.publish(activity, feeds) do
ap_publish("create", proposal.id, creator.id)
end
end
defp publish(proposal, :updated) do
# TODO: wrong if edited by admin
ap_publish("update", proposal.id, proposal.creator_id)
......
......@@ -72,7 +72,7 @@ defmodule ValueFlows.Test.Faking do
finished: assert_optional(&assert_boolean/1),
created: assert_optional(&assert_datetime/1),
due: assert_optional(&assert_datetime/1),
resource_classified_as: assert_optional(assert_list(&assert_url/1)),
resource_classified_as: assert_optional(assert_list(&assert_url/1))
)
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment