forked from johnymontana/lobste.rs-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (78 loc) · 3.08 KB
/
lobsters.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Lobsters Data Import
on:
push:
paths:
- .github/workflows/lobsters.yml
workflow_dispatch:
schedule:
- cron: '*/60 * * * *'
jobs:
scheduled:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v2
- name: Fetch newest
uses: githubocto/flat@v2
with:
http_url: https://lobste.rs/newest.json
downloaded_filename: newest.json
- name: Neo4j import newest
uses: johnymontana/[email protected]
with:
neo4j-user: ${{secrets.NEO4J_USER}}
neo4j-password: ${{secrets.NEO4J_PASSWORD}}
neo4j-uri: ${{secrets.NEO4J_URI}}
filename: newest.json
cypher-query: >
UNWIND $value AS article
MERGE (s:User {username: article.submitter_user.username})
SET s.created = DateTime(article.submitter_user.created_at),
s.karma = article.submitter_user.karma,
s.about = article.submitter_user.about,
s.avatar = "https://lobste.rs" + article.submitter_user.avatar_url
MERGE (i:User {username: article.submitter_user.invited_by_user})
MERGE (i)<-[:INVITED_BY]-(s)
MERGE (a:Article {id: article.short_id})
SET a.url = article.url,
a.score = article.score,
a.title = article.title,
a.comments = article.comments_url,
a.created = DateTime(article.created_at)
MERGE (s)-[:SUBMITTED]->(a)
WITH article, a
UNWIND article.tags AS tag
MERGE (t:Tag {name: tag})
MERGE (a)-[:HAS_TAG]->(t)
- name: Fetch hottest
uses: githubocto/flat@v2
with:
http_url: https://lobste.rs/hottest.json
downloaded_filename: hottest.json
- name: Neo4j import hottest
uses: johnymontana/[email protected]
with:
neo4j-user: ${{secrets.NEO4J_USER}}
neo4j-password: ${{secrets.NEO4J_PASSWORD}}
neo4j-uri: ${{secrets.NEO4J_URI}}
filename: hottest.json
cypher-query: >
UNWIND $value AS article
MERGE (s:User {username: article.submitter_user.username})
SET s.created = DateTime(article.submitter_user.created_at),
s.karma = article.submitter_user.karma,
s.about = article.submitter_user.about,
s.avatar = "https://lobste.rs" + article.submitter_user.avatar_url
MERGE (i:User {username: article.submitter_user.invited_by_user})
MERGE (i)<-[:INVITED_BY]-(s)
MERGE (a:Article {id: article.short_id})
SET a.url = article.url,
a.score = article.score,
a.title = article.title,
a.comments = article.comments_url,
a.created = DateTime(article.created_at)
MERGE (s)-[:SUBMITTED]->(a)
WITH article, a
UNWIND article.tags AS tag
MERGE (t:Tag {name: tag})
MERGE (a)-[:HAS_TAG]->(t)