|
|
@@ -13,9 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
13
|
13
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
14
|
14
|
import org.springframework.web.bind.annotation.RestController;
|
|
15
|
15
|
|
|
16
|
|
-import java.util.Collection;
|
|
17
|
16
|
import java.util.HashMap;
|
|
18
|
|
-import java.util.HashSet;
|
|
19
|
17
|
|
|
20
|
18
|
@RestController
|
|
21
|
19
|
public class ComputeResultController {
|
|
|
@@ -42,18 +40,18 @@ public class ComputeResultController {
|
|
42
|
40
|
for (Vote v: allVotes
|
|
43
|
41
|
) {
|
|
44
|
42
|
voteCount++;
|
|
45
|
|
- Long name = (v.getOption().getId());
|
|
46
|
|
- if (!optionCountsMap.keySet().contains(name)) {
|
|
47
|
|
- optionCountsMap.put(name, new OptionCount());
|
|
|
43
|
+ Long optionID = (v.getOption().getId());
|
|
|
44
|
+ if (!optionCountsMap.keySet().contains(optionID)) {
|
|
|
45
|
+ optionCountsMap.put(optionID, new OptionCount());
|
|
|
46
|
+// optionCountsMap.get(optionID).setCount(1);
|
|
48
|
47
|
} else {
|
|
49
|
|
- OptionCount temp = optionCountsMap.get(name);
|
|
|
48
|
+ OptionCount temp = optionCountsMap.get(optionID);
|
|
50
|
49
|
temp.setCount(temp.getCount()+1);
|
|
51
|
|
- optionCountsMap.replace(name, temp);
|
|
|
50
|
+ optionCountsMap.replace(optionID, temp);
|
|
52
|
51
|
}
|
|
53
|
52
|
}
|
|
54
|
53
|
|
|
55
|
54
|
voteResult.setTotalVotes(voteCount);
|
|
56
|
|
-
|
|
57
|
55
|
voteResult.setResults(optionCountsMap.values());
|
|
58
|
56
|
|
|
59
|
57
|
//TODO: Implement algorithm to count votes
|