-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjectProcessor.js
More file actions
73 lines (65 loc) · 1.96 KB
/
objectProcessor.js
File metadata and controls
73 lines (65 loc) · 1.96 KB
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
function getVoteSentiment(vote) {
if (vote == 5 || vote == 4) {
return -1 * vote;
} else if (vote == 1 || vote == 2) {
return vote;
} else return 0;
}
/*
description - File to process the User json file and prepares the list of users for a percticular location, designation and department
*/
function processOneUser(data, jsonMap, es) {
jsonMap.set("totalUsers", jsonMap.get("totalUsers") + 1);
// location list
if (jsonMap.has("location")) {
jsonMap.get("location").push(data["location"]);
} else {
jsonMap.set("location", [data["location"]]);
}
// designation list
if (jsonMap.has("designation")) {
jsonMap.get("designation").push(data["designation"]);
} else {
jsonMap.set("designation", [data["designation"]]);
}
// department list
if (jsonMap.has("department")) {
jsonMap.get("department").push(data["department"]);
} else {
jsonMap.set("department", [data["department"]]);
}
// location
if (jsonMap.has(data["location"])) {
jsonMap.get(data["location"]).push(data["User"]);
} else {
jsonMap.set(data["location"], [data["User"]]);
}
// designation
if (jsonMap.has(data["designation"])) {
jsonMap.get(data["designation"]).push(data["User"]);
} else {
jsonMap.set(data["designation"], [data["User"]]);
}
// department
if (jsonMap.has(data["department"])) {
jsonMap.get(data["department"]).push(data["User"]);
} else {
jsonMap.set(data["department"], [data["User"]]);
}
es.resume();
}
/*
description - File to process the Votes json file and calculate the user's vote sentiment
*/
function processOneVote(data, jsonMap, es) {
if (jsonMap.has(data["userId"])) {
let votes = jsonMap.get(data["userId"]);
votes = votes + getVoteSentiment(data["Vote"]);
jsonMap.set(data["userId"], votes);
} else {
jsonMap.set(data["userId"], getVoteSentiment(data["Vote"]));
}
es.resume();
}
exports.processOneUser = processOneUser;
exports.processOneVote = processOneVote;