Commit a1567bcc authored by Fjen Undso's avatar Fjen Undso
Browse files

VoteController: sum of votes for stats. faster negative all rating. fixes #1

parent 194d9a90
......@@ -121,10 +121,10 @@ public class VoteController extends Controller {
if (v.date.after(tenMinutesAgo)) {
switch (v.type) {
case SPEED:
sSpeed.value = v.value;
sSpeed.value += v.value;
break;
case UNDERSTANDABILITY:
sUnderstandability.value = v.value;
sUnderstandability.value += v.value;
break;
case REQUEST:
// consider only last 30sek
......@@ -150,7 +150,12 @@ public class VoteController extends Controller {
// arithmetic mean of votes
sSpeed.value = sSpeed.value / sUsers.value;
sUnderstandability.value = sUnderstandability.value / sUsers.value;
sAll.value = (100 - (Math.abs(sSpeed.value - 50) * 2) + sUnderstandability.value) / 2;
if (20 < sSpeed.value || sSpeed.value > 80 || sUnderstandability.value < 20) {
// give negative overall rating, is one value is very bad
sAll.value = 0;
} else {
sAll.value = (100 - (Math.abs(sSpeed.value - 50) * 2) + sUnderstandability.value) / 2;
}
}
return ok(Json.toJson(vsList)); // 200
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment