This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Repository { | |
url: ID! | |
created_at: DateTime | |
description: String | |
name: String | |
website: String | |
webhooks: [Webhook] @relation(name: "HAS_WEBHOOK", direction: "OUT") | |
pull_requests: [PullRequest] @relation(name: "BASE", direction: "IN") | |
pr_count: Int @cypher(statement: "RETURN SIZE((this)<-[:BASE]-())") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CALL apoc.load.json("file:///Users/lyonwj/Desktop/pull_requests_000001.json") YIELD value | |
MERGE (pr:PullRequest {url: value.url}) | |
SET pr += value{created_at: DateTime(value.created_at), closed_at: DateTime(value.closed_at), merged_at: DateTime(value.merged_at), .title, .body } | |
MERGE (head:Repository {url: coalesce(value.head.repo,"")}) | |
MERGE (head)<-[h:HEAD]-(pr) | |
SET h = {sha: value.head.sha, ref: value.head.ref} | |
MERGE (base:Repository {url: value.base.repo}) | |
MERGE (base)<-[b:BASE]-(pr) | |
SET b = {sha: value.base.sha, ref: value.base.ref} | |
MERGE (u:User {url: value.user}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CALL apoc.load.json("file:///Users/lyonwj/Desktop/users_000001.json") YIELD value | |
MERGE (u:User {url: value.url}) | |
SET u += value {created_at: DateTime(value.created_at), .avatar_url, .website, .name, .bio, .company, .location, .login} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load repositories | |
UNWIND ["repositories_000001.json", "repositories_000002.json"] AS file | |
CALL apoc.load.json($baseURL + file) YIELD value | |
// only import public repos | |
WITH value AS repo WHERE repo.private = false | |
MERGE (r:Repository {url: repo.url}) | |
SET r += repo {.name, .description, .website, created_at: DateTime(repo.created_at)} | |
MERGE (u:User {url: repo.owner}) | |
MERGE (r)<-[:OWNS]-(u) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE CONSTRAINT ON (r:Repository) ASSERT r.url IS UNIQUE; | |
CREATE CONSTRAINT ON (u:User) ASSERT u.url IS UNIQUE; | |
CREATE CONSTRAINT ON (h:Webhook) ASSERT h.url IS UNIQUE; | |
CREATE CONSTRAINT ON (p:PullRequest) ASSERT p.url IS UNIQUE; | |
CREATE CONSTRAINT ON (i:Issue) ASSERT i.url IS UNIQUE; | |
CREATE CONSTRAINT ON (c:IssueComment) ASSERT c.url IS UNIQUE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// defined in App.js, this function is passed to the | |
// Map component as a prop | |
mapSearchPointChange = viewport => { | |
this.setState({ | |
mapCenter: { | |
...this.state.mapCenter, | |
latitude: viewport.latitude, | |
longitude: viewport.longitude, | |
zoom: viewport.zoom |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// event handler for draggable marker in Map component | |
const onDragEnd = e => { | |
var lngLat = e.target.getLngLat(); | |
const viewport = { | |
latitude: lngLat.lat, | |
longitude: lngLat.lng, | |
zoom: this.map.getZoom() | |
}; | |
this.props.mapSearchPointChange(viewport); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Date } from "neo4j-driver/lib/v1/temporal-types"; | |
fetchBusinesses = () => { | |
const { mapCenter, startDate, endDate } = this.state; | |
const session = this.driver.session(); | |
session.run(` | |
MATCH (b:Business)<-[:REVIEWS]-(r:Review) | |
WHERE $start <= r.date <= $end | |
AND distance(b.location, | |
point({latitude: $lat, longitude: $lon})) < ( $radius * 1000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import the web brower version of neo4j-javascript-driver | |
import neo4j from "neo4j-driver/lib/browser/neo4j-web"; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = ... // set default state | |
// instantiate Neo4j driver instance | |
this.driver = neo4j.driver( | |
process.env.REACT_APP_NEO4J_URI, | |
neo4j.auth.basic( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation { | |
m1: createMovie(id: "101", title: "Black Panther", tagline: "", released: 2018) | |
m2: createMovie(id: "107", title: "Snatch", tagline: "Unscrupulous boxing promoters, violent bookmakers, a Russian gangster, incompetent amateur robbers...", released: 2000) | |
m3: createMovie(id: "108", title: "River Runs Through It, A", tagline: "The story about two sons of a stern minister -- one reserved, one rebellious -- growing up in rural Montana while devoted to fly fishing.", released: 1992) | |
m4: createMovie(id: "71573", title: "Whiteout", tagline: "U.S. Marshal Carrie Stetko tracks a killer in Antarctica, as the sun is about to set for six months", released: 2009) | |
p1: createPerson(id: "p1", name:"Tom Skerritt", born: 1933) | |
p2: createPerson(id: "p2", name: "Brad Pitt", born: 1963) | |
cast1: addMovieActors(id: "108", actors: ["p1", "p2"]) | |
cast2: addMovieActors(id: "71573", actors: ["p1"]) |