This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysis.js
61 lines (53 loc) · 1.94 KB
/
analysis.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
'use strict'
const fs = require('fs')
const path = require('path')
const analyze = (name) => {
const pathToFile = `./output/${name}.json`
if (!fs.existsSync(pathToFile)) {
console.log(`file ${pathToFile} not found!`)
process.exit(1)
}
var userData = JSON.parse(fs.readFileSync(pathToFile, 'utf-8').toString())
console.log('=============================================')
console.log(`Summary for ${name}.json`)
var ideaLookup = {}
Object.keys(userData).forEach(username => {
userData[username].roundTwoIdeas.forEach(idea => {
ideaLookup[idea.ideaId] = idea
})
})
var fixationScoreGroupTotal = 0
Object.keys(userData).forEach(username => {
console.log('---------------------------------------------')
console.log(`${username}'s data:`)
let fixationScoreTotal = 0
Object.keys(userData[username].roundVote).forEach(ideaId => {
if (userData[username].roundVote[ideaId]) {
console.log(`voted for ${ideaId}:`)
let ideaObj = ideaLookup[ideaId]
console.log(JSON.stringify(ideaObj, null, 4))
let fixationScore = 0
if (ideaObj.originOwner === username) {
fixationScore++
console.log('(+1) Is owner of idea that inspired this idea.')
}
if (ideaObj.owner === username) {
fixationScore++
console.log('(+1) Is owner of idea.')
}
fixationScoreTotal += fixationScore
}
})
console.log(`${username}'s total fixation score was ${fixationScoreTotal}`)
fixationScoreGroupTotal += fixationScoreTotal
})
console.log('---------------------------------------------')
console.log(`Group total fixation score: ${fixationScoreGroupTotal}`)
console.log(`Group mean fixation score: ${fixationScoreGroupTotal / Object.keys(userData).length}`)
console.log('=============================================')
}
if (require.main === module) {
analyze(process.argv[2])
} else {
module.exports = analyze
}