Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoturf queue job #52

Open
cormander opened this issue Apr 18, 2020 · 1 comment
Open

Autoturf queue job #52

cormander opened this issue Apr 18, 2020 · 1 comment

Comments

@cormander
Copy link

As a developer I want to create a queue job for autoturf so that it can be called from the API.

This feature is done when:

  • A queue job exists to execute autoturf
  • The autoturf query is modified as necessary to reflect current schema and coding conventions
@cormander
Copy link
Author

POC autoturf query is as follows:

call apoc.periodic.commit('match (at:Attribute {id:"4a320f76-ef7b-4d73-ae2a-8f4ccf5de344"}) match (t:Turf {id:"7a84e51a-6998-4092-820b-cd556e24bc23"}) match (a:Address)-[:WITHIN]->(t) where a.red is null match (p:Person)-[:RESIDENCE]->(a) match (at)<-[:ATTRIBUTE_TYPE]-(pa:PersonAttribute {value:"Republican"})-[:ATTRIBUTE_OF]->(p) with a limit 10000 set a.red = true return count(a)', {}) yield updates as red
call apoc.periodic.commit('match (at:Attribute {id:"4a320f76-ef7b-4d73-ae2a-8f4ccf5de344"}) match (t:Turf {id:"7a84e51a-6998-4092-820b-cd556e24bc23"}) match (a:Address)-[:WITHIN]->(t) where a.blue is null match (p:Person)-[:RESIDENCE]->(a) match (at)<-[:ATTRIBUTE_TYPE]-(pa:PersonAttribute {value:"Democratic"})-[:ATTRIBUTE_OF]->(p) with a limit 10000 set a.blue = true return count(a)', {}) yield updates as blue
call apoc.periodic.commit('
match (a:Address) where a.red = true
with point({longitude: avg(a.position.x), latitude: avg(a.position.y)}) as center
match (a:Address) where a.red = true
with a, distance(center, a.position) as dist order by dist desc limit 1
match (b:Address) where b.red = true
with b, distance(a.position, b.position) as dist order by dist limit 20
with point({longitude: avg(b.position.x), latitude: avg(b.position.y)}) as center, collect(b) as addrs
where length(addrs) > 0
create (l:ListRed {id:randomUUID(), center: center})
with l, addrs
unwind addrs as a
merge (l)<-[:LIST_MEMBER]-(a)
set a.red = null
return count(l)', {}) yield updates as updatesred
call apoc.periodic.commit('
match (a:Address) where a.blue = true
with point({longitude: avg(a.position.x), latitude: avg(a.position.y)}) as center
match (a:Address) where a.blue = true
with a, distance(center, a.position) as dist order by dist desc limit 1
match (b:Address) where b.blue = true
with b, distance(a.position, b.position) as dist order by dist limit 5
with point({longitude: avg(b.position.x), latitude: avg(b.position.y)}) as center, collect(b) as addrs
where length(addrs) > 0
create (l:ListBlue {id:randomUUID(), center: center})
with l, addrs
unwind addrs as a
merge (l)<-[:LIST_MEMBER]-(a)
set a.blue = null
return count(l)', {}) yield updates as updatesblue
call apoc.periodic.commit('
match (lr:ListRed) where lr.joined is null with point({longitude: avg(lr.center.x), latitude: avg(lr.center.y)}) as center
match (lr:ListRed) where lr.joined is null with lr, distance(center, lr.center) as dist order by dist desc limit 1
match (lb:ListBlue) with lr, lb, distance(lr.center, lb.center) as dist order by dist limit 1
match (lb)<-[:LIST_MEMBER]-(a:Address)
merge (lr)<-[:LIST_MEMBER]-(a)
detach delete lb
set lr.joined = true
return count(a)', {}) yield updates as updatesjoinred
call apoc.periodic.commit('
match (lb:ListBlue) with lb limit 1
match (lr:ListRed) with lr, lb, distance(lr.center, lb.center) as dist order by dist limit 1
match (lb)<-[:LIST_MEMBER]-(a:Address)
merge (lr)<-[:LIST_MEMBER]-(a)
detach delete lb
return count(a)', {}) yield updates return updates;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant