Skip to content

Commit

Permalink
Remove cap and minimum for IM points
Browse files Browse the repository at this point in the history
  • Loading branch information
benthemonkey committed Mar 14, 2016
1 parent 7100208 commit 151c636
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 25 deletions.
25 changes: 18 additions & 7 deletions ajax/PointsCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,24 @@ public function getEventTotals()

public function getIMPoints()
{
return self::fetchAllQuery(
"SELECT nu_email, LEAST(SUM(count),15) AS total
FROM imcounts
WHERE count>=3 AND qtr=:qtr
GROUP BY nu_email",
PDO::FETCH_KEY_PAIR
);
// There is not a minimum or maximum beginning Winter 2016
if (self::$qtr >= 1601) {
return self::fetchAllQuery(
"SELECT nu_email, SUM(count) AS total
FROM imcounts
WHERE qtr=:qtr
GROUP BY nu_email",
PDO::FETCH_KEY_PAIR
);
} else {
return self::fetchAllQuery(
"SELECT nu_email, LEAST(SUM(count),15) AS total
FROM imcounts
WHERE count>=3 AND qtr=:qtr
GROUP BY nu_email",
PDO::FETCH_KEY_PAIR
);
}
}

public function getSlivkanPoints($nu_email)
Expand Down
50 changes: 32 additions & 18 deletions js/points-center/breakdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,44 @@ var getSlivkanPoints = function() {

if (data.ims.length > 0) {
$imsChart.show();
_.forEach(data.ims, function(im) {
im.count = parseInt(im.count, 10);

imData.push([im.sport, im.count]);
// There is not a minimum or maximum beginning Winter 2016
if (qtr >= 1601) {
_.forEach(data.ims, function(im) {
im.count = parseInt(im.count, 10);

imData.push([im.sport, im.count]);

if (im.count >= 3) {
imTotal += im.count;
} else {
imExtra += im.count;
});

drawChart($imsChart, imData, 'IM Points (' + imTotal + ' Total)', width);
} else {
_.forEach(data.ims, function(im) {
im.count = parseInt(im.count, 10);

imData.push([im.sport, im.count]);

if (im.count >= 3) {
imTotal += im.count;
} else {
imExtra += im.count;
}
});

if (imTotal > 15) {
imExtra += imTotal - 15;
imTotal = 15;
}
});

if (imTotal > 15) {
imExtra += imTotal - 15;
imTotal = 15;
drawChart(
$imsChart,
imData,
['IMs (', imTotal, ' Points, ', imExtra,
(imExtra === 1 ? ' Doesn\'t' : ' Don\'t'), ' Count)'].join(''),
width
);
}

drawChart(
$imsChart,
imData,
['IMs (', imTotal, ' Points, ', imExtra,
(imExtra === 1 ? ' Doesn\'t' : ' Don\'t'), ' Count)'].join(''),
width
);
} else {
$imsChart.hide();
}
Expand Down

0 comments on commit 151c636

Please sign in to comment.