Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/liquid_voting/voting.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ defmodule LiquidVoting.Voting do

"""
def create_vote(attrs \\ %{}) do
Tracer.with_span "operation" do
Tracer.set_attributes([{:a_key, "a_value"}])
end

Repo.transaction(fn ->
# TODO: refactor case statements into small functions.

Expand Down Expand Up @@ -65,10 +61,14 @@ defmodule LiquidVoting.Voting do

"""
def list_votes(organization_id) do
Vote
|> where(organization_id: ^organization_id)
|> Repo.all()
|> Repo.preload([:participant])
Tracer.with_span "LV/voting" do
Tracer.set_attributes([{:action, "list_votes"}, {:organization_id, organization_id}])

Vote
|> where(organization_id: ^organization_id)
|> Repo.all()
|> Repo.preload([:participant])
end
end

@doc """
Expand Down
11 changes: 9 additions & 2 deletions lib/liquid_voting_web/resolvers/voting.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
defmodule LiquidVotingWeb.Resolvers.Voting do
require OpenTelemetry.Tracer, as: Tracer

alias LiquidVoting.{Voting, VotingResults}
alias LiquidVotingWeb.Schema.ChangesetErrors

Expand All @@ -25,8 +27,13 @@ defmodule LiquidVotingWeb.Resolvers.Voting do
def votes(_, %{proposal_url: proposal_url}, %{context: %{organization_id: organization_id}}),
do: {:ok, Voting.list_votes_by_proposal(proposal_url, organization_id)}

def votes(_, _, %{context: %{organization_id: organization_id}}),
do: {:ok, Voting.list_votes(organization_id)}
def votes(_, _, %{context: %{organization_id: organization_id}}) do
Tracer.with_span "resolvers/voting" do
Tracer.set_attributes([{:action, "votes"}, {:organization_id, organization_id}])

{:ok, Voting.list_votes(organization_id)}
end
end

def vote(_, %{id: id}, %{context: %{organization_id: organization_id}}),
do: {:ok, Voting.get_vote!(id, organization_id)}
Expand Down