-
Notifications
You must be signed in to change notification settings - Fork 31
/
ens_gift.js
55 lines (48 loc) · 1.38 KB
/
ens_gift.js
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
const postgres = require('postgres')
const fs = require('fs')
const sql = postgres({
host: process.env.PGHOST,
database: process.env.PGDATABASE,
password: process.env.PGPASSWORD,
username: process.env.PGUSER,
port: process.env.PGPORT,
ssl: 'prefer',
max: 2,
connection: {
application_name: 'script',
},
idle_timeout: 30,
})
let ens_regex = /\.eth|\.𝚎𝚝𝚑|\.Ξth|\.⟠|dot eth/i
let ens_fam = []
function process_batch(accounts) {
accounts.forEach(function(account) {
if(
account.name?.match(ens_regex) ||
account.bio?.match(ens_regex) ||
account.location?.match(ens_regex)
) {
ens_fam.push({
id: account.twitter_id,
handle: account.handle,
name: account.name,
bio: account.bio,
location: account.location,
})
}
})
}
(async function() {
let total_processed = 0
await sql`
SELECT * FROM twitter_accounts ORDER BY handle
`.cursor(10000, async (batch) => {
process_batch(batch)
total_processed += batch.length
console.log(total_processed, 'processed')
})
console.log(ens_fam.length)
fs.writeFile('./processed/ens_fam.json', JSON.stringify(ens_fam, null, ' '), function (err) {
if (err) console.log(err)
})
}())