-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyize.js
80 lines (75 loc) · 2.54 KB
/
analyize.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
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
const DataLoader = require('./analysis/dataLoader')
const DumpProcessor = require('./analysis/dumpProcessor')
const ArchivedDumpProcessor = require('./analysis/archive/dumpProcessor')
const runPromise = require('./runPromise')
const fs = require('fs-extra')
const _ = require('lodash')
const path = require('path')
const {URL} = require('url')
const isURL = require('validator/lib/isURL')
// analizedDump
async function doIt () {
const apps = await DataLoader.loadApps()
const dumpProcessor = DumpProcessor.newOne(apps)
const dumps = await DataLoader.sortedRead()
let i = 0
let len = dumps.length
let aDump
while (i < len) {
// console.log(dumps[i])
aDump = await DataLoader.getJsonData(dumps[i].path)
dumpProcessor.init()
dumpProcessor.process(aDump, dumps[i].rank)
await fs.writeJSON(`analizedDump/${dumps[i].fname}`, dumpProcessor, {spaces: 2})
i++
}
}
async function doIt2 () {
const apps = await DataLoader.loadApps()
const dumpProcessor = ArchivedDumpProcessor.newOne(apps)
const dumps = await DataLoader.listDir('archiveDumps')
let i = 0
let len = dumps.length
let aDump
let wasError = false
// console.log(dumps.filter(it => _.isNil(it.path)))
while (i < len) {
// console.log(dumps[i].fname)
if (dumps[i] !== undefined) {
wasError = false
aDump = await DataLoader.getJsonData(dumps[i].path)
dumpProcessor.init()
try {
dumpProcessor.process(aDump)
} catch (error) {
// console.error(error)
wasError = true
}
if (!wasError) {
await fs.writeJSON(`analizedArchiveDumps/${dumps[i].fname}`, dumpProcessor, {spaces: 2})
}
}
i++
}
}
async function doIt3 () {
// const twitterSeedList = await DataLoader.getJsonData('twitterSeedList.json')
// const twitterSeedListTodo = await DataLoader.getJsonData('todoTwitterSeedsList.json')
// console.log(twitterSeedList.length)
// console.log(twitterSeedListTodo.length)
const apps = await DataLoader.loadApps()
const dumpProcessor = DumpProcessor.newOne(apps)
const twitterDump = await DataLoader.listDir('twitterSeedDump')
let len = twitterDump.length
let i = 0
let aDump
while (i < len) {
aDump = await DataLoader.getJsonData(twitterDump[i].path)
dumpProcessor.init()
dumpProcessor.process(aDump)
// console.log(dumpProcessor.domProcessor)
await fs.writeJSON(`analizedTwitterDump/${twitterDump[i].fname}`, dumpProcessor, {spaces: 2})
i++
}
}
runPromise(doIt).then(() => runPromise(doIt2).then(() => runPromise(doIt3)).then(() => console.log('done')))