summaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/playerStats.php24
1 files changed, 5 insertions, 19 deletions
diff --git a/includes/playerStats.php b/includes/playerStats.php
index 5640dc7..eff2013 100644
--- a/includes/playerStats.php
+++ b/includes/playerStats.php
@@ -160,27 +160,11 @@ function addPlayerChampionPointsForMapsOfTheDay($mapExpireStartRange, $mapExpire
";
//TODO: Points for doing challenges too
- //TODO: Is summing the entire table every time slow? If so, we should just add the points instead
- $sql5 = "
- -- Simply re-sum all the points
- UPDATE users
- INNER JOIN
- (
- SELECT SUM(solutions.championPointsWorth) AS championPointsWorth, solutions.userID
- FROM solutions
- INNER JOIN mapOfTheDay ON solutions.mapID = mapOfTheDay.mapID
- WHERE mapOfTheDay.mapExpireTime >= $mapExpireStartRange
- AND mapOfTheDay.mapExpireTime <= $mapExpireEndRange
- GROUP BY solutions.userID
- ) AS newPointsEarned ON users.ID = newPointsEarned.userID
- SET users.championPoints = users.championPoints + newPointsEarned.championPointsWorth
- ";
mysql_query($sql1);
mysql_query($sql2);
mysql_query($sql3);
mysql_query($sql4);
- mysql_query($sql5);
}
/**
@@ -190,7 +174,7 @@ function clearAllStatsBeforeRecalculation()
{
$sql1 = "
UPDATE users
- SET totalWins = 0, totalTies = 0, totalMazes = 0, totalMoves = 0;
+ SET totalWins = 0, totalTies = 0, totalMazes = 0, totalMoves = 0, championPoints = 0;
";
$sql2 = "
@@ -225,7 +209,8 @@ function addOtherStats($mapExpireStartRange, $mapExpireEndRange = "NOW()")
SUM(isHighScore) AS totalWins,
SUM(isTiedForHighScore) AS totalTies,
SUM(solutions.moves) AS totalMoves,
- COUNT(*) AS totalMazes
+ COUNT(*) AS totalMazes,
+ SUM(solutions.championPointsWorth) AS championPointsWorth
FROM solutions
INNER JOIN mapOfTheDay ON solutions.mapID = mapOfTheDay.mapID
WHERE mapOfTheDay.mapExpireTime >= $mapExpireStartRange
@@ -235,7 +220,8 @@ function addOtherStats($mapExpireStartRange, $mapExpireEndRange = "NOW()")
SET users.totalWins = users.totalWins + newPoints.totalWins,
users.totalTies = users.totalTies + newPoints.totalTies,
users.totalMoves = users.totalMoves + newPoints.totalMoves,
- users.totalMazes = users.totalMazes + newPoints.totalMazes
+ users.totalMazes = users.totalMazes + newPoints.totalMazes,
+ users.championPoints = users.championPoints + newPoints.championPointsWorth
";
mysql_query($sql);