-
Notifications
You must be signed in to change notification settings - Fork 8
/
find_some_replies.ts
56 lines (34 loc) · 1.01 KB
/
find_some_replies.ts
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
require('dotenv').config()
import models from './src/models'
import { Op } from 'sequelize'
import { cacheContent } from './src/content'
async function main(){
console.log('about to find all')
let txns = await models.BmapTransaction.findAll({
order: [['createdAt', 'desc']],
limit: 10000,
where: {
bmap: {[Op.ne]: null}
}
})
for (let tx of txns) {
if (tx.bmap && tx.bmap && tx.bmap.MAP && tx.bmap.MAP[0].context === 'tx' && tx.bmap.MAP[0].tx != 'null'){
console.log(tx.bmap.MAP)
let originalPost = await models.Content.findOne({
where: {
txid: tx.bmap.MAP[0].tx
}
})
if (originalPost) {
console.log(originalPost.toJSON(), 'OP')
console.log(tx)
let [content] = await cacheContent(tx.txid)
if (!content.get('context_txid')) {
await content.set('context_txid', tx.bmap.MAP[0].tx)
console.log(content.toJSON(), 'reply.imported')
}
}
}
}
}
main()