# Goal creation queries
## first, connect the tokens to the goal
```
with
$addresses as addresses, $goalId as goalId
match
(g:_Goal {_goalId: $goalId})
match
(t:Token)
where
t.address in addresses
with
t, g
merge
(g)-[:_HAS_GOAL_TOKEN]->(t)
return
count(distinct(t))
```
## Connect highly engaged voters to goal
```
match
(g:_Goal {_goalId: $goalId})-[r:_HAS_GOAL_TOKEN]->(t:Token)
with
t,g
match
(w:Wallet)-[r:VOTED]->(p:Proposal)-[:HAS_PROPOSAL]-(e:Entity)-[:HAS_STRATEGY]-(t:Token)
with
w, count(distinct(r)) as votes, t,g
with
apoc.agg.percentiles(votes, [.8])[0] as threshold, t, g
match
(w:Wallet)-[r:VOTED]->(p:Proposal)-[:HAS_PROPOSAL]-(e:Entity)-[:HAS_STRATEGY]-(t:Token)
with
w, count(distinct(p)) as votes, threshold, g
where
votes > threshold
with
w, g
merge
(w)-[:_HIGHLY_ENGAGED]->(g)
return
count(distinct(w)) as count
```
## Connect voters to audience
```
match
(g:_Goal {_goalId: $goalId})-[:_HAS_GOAL_TOKEN]-(t:Token)
match
(w:Wallet)-[:_HIGHLY_ENGAGED]->(g)
match
(w)-[:VOTED]->(p:Proposal)-[:VOTED]-(x:Wallet)
and not
(x)-[:_HIGHLY_ENGAGED|_ENGAGED_AUDIENCE]->(g)
and not
(p)-[:HAS_PROPOSAL]-(e:TooBig)
with
w, g
merge
(w)-[r:_ENGAGED_AUDIENCE]->(g)
set
r.type = 'Voting'
return
count(distinct(r))
```
## Connect related donors to audience
```
match
(g:_Goal {_goalId: $goalId})-[:_HAS_GOAL_TOKEN]-(t:Token)
match
(w:Wallet)-[:_HIGHLY_ENGAGED]->(g)
match
(w:Wallet)-[:DONATION]->(y:Grant)-[]-(x:Wallet)-[:_HAS_CONTEXT]-(context)
where not
(x)-[:_HIGHLY_ENGAGED|_ENGAGED_AUDIENCE]->(g)
and not
(x)-[:_HAS_CONTEXT]->(g)
and not
y:TooBig
merge
(x)-[r:_ENGAGED_AUDIENCE]->(g)
set
r.type = "Grants"
return
count(distinct(r))
```
## Connect holders of related tokens
```
with
$addresses as addresses
match
(w:Wallet)-[:_HIGHLY_ENGAGED]->(goal:_Goal {_goalId: $_goalId: $_goalId: $})
match
(w:Wallet)-[r:HOLDS]->(token:Token:ArtisanToken)<-[:HOLDS]-(x:Wallet)
where
element.address in addresses
and not
(x)-[:_HIGHLY_ENGAGED]->(element)
and not
(x)-[:_HAS_CONTEXT]->(:_IncentiveFarming)
with
x, goal
merge
(x)-[r:_HIGHLY_ENGAGED]->(goal)
set
r.type = "Tokens"
return
count(distinct(r))
```