summaryrefslogtreecommitdiffstats
path: root/includes/datas.php
diff options
context:
space:
mode:
authorBlueRaja <BlueRaja.admin@gmail.com>2013-01-13 19:27:39 -0600
committerBlueRaja <BlueRaja.admin@gmail.com>2013-01-13 19:27:39 -0600
commit099e2d5ab8effe07b0e5d8c59e18c81f519fd833 (patch)
treeb23c9a4291b1391382bdf4424bb7a948a287e76d /includes/datas.php
parent35307251560e459615f2a3e5ab6572b3f80cfdd9 (diff)
downloadpathery-099e2d5ab8effe07b0e5d8c59e18c81f519fd833.tar.xz
Added totalWins and totalTies columns to the users table. Also, removed all references to the 'statistics' table - it's not needed anymore.
Diffstat (limited to 'includes/datas.php')
-rw-r--r--includes/datas.php82
1 files changed, 5 insertions, 77 deletions
diff --git a/includes/datas.php b/includes/datas.php
index 6d73230..b29f1c9 100644
--- a/includes/datas.php
+++ b/includes/datas.php
@@ -572,11 +572,9 @@ function getAchievementCurrency($userID, $aType) {
WHERE userID = '$userID'";
break;
case 3:
- $sql = "SELECT
- SUM(`value`) as t
- FROM `statistics`
- WHERE `userID` = '$userID'
- AND `type` IN (1, 2, 3, 4)";
+ $sql = "SELECT totalTies
+ FROM `users`
+ WHERE `userID` = '$userID'";
break;
case 4:
$sql = "SELECT championPoints
@@ -711,74 +709,6 @@ function getChampionPointsArray() {
return $r;
}
-//Used to track statistics on who wins or ties maps at the end of a day.
-function trackMOTDstats($mapType) {
- // Our rather massive query to get the data we need.
- $sql = "SELECT
- users.ID as userID,
- SUM(solutions.moves) as Moves,
- timediff(MAX(dateModified), maps.dateCreated) as Timetaken
- FROM `maps`
- JOIN `solutions`
- ON maps.ID = solutions.mapID
- JOIN `users`
- ON solutions.userID = users.ID
- JOIN `mapOfTheDay`
- ON maps.ID = mapOfTheDay.mapID
- WHERE
- DATE_ADD(CURDATE(), INTERVAL -1 DAY) =
- DATE_FORMAT(solutions.dateModified,'%Y-%m-%d')
- AND DATE_ADD(CURDATE(), INTERVAL -1 DAY) =
- DATE_FORMAT(maps.dateCreated,'%Y-%m-%d')
- AND `mapType` = '$mapType'
- GROUP BY solutions.userID
- ORDER BY Moves DESC, MAX(dateModified) ASC, solutions.ID DESC
- ";
-
- $mainResult = mysql_query($sql);
- if ($mainResult) {
- $first = true;
- while (list($userID, $uMoves, $uTimeTaken) = mysql_fetch_row($mainResult)) {
- //echo "$first : userID: $userID uMoves: $uMoves uTimeTaken: $uTimeTaken mapType: $mapType<br >";
- do {
- //If it's the rank #1 user, we need to repeat to also award him the tie stat.
- $repeatThis = false;
- $sType = $mapType;
- if ($first) {
- $bestMoves = $uMoves;
- $sType = 31 + $mapType;
- $repeatThis = true;
- }
- if ($uMoves == $bestMoves) {
- $sql = "SELECT `ID` FROM `statistics`
- WHERE `userID` = '$userID' AND `type` = '$sType'";
- $result = mysql_query($sql);
-
- if (mysql_num_rows($result) == 0) {
- $sql = "INSERT INTO `statistics` (`userID`, `type`, `value`)
- VALUES ('$userID', '$sType', 1)";
- $result = mysql_query($sql);
- if (!$result)
- return false;
- } else {
- $sql = "UPDATE `statistics`
- SET `value` = `value` + 1
- WHERE `userID` = '$userID' AND `type` = '$sType'";
- $result = mysql_query($sql);
- if (!$result)
- return false;
- }
-
- } else {
- break 2;
- }
- $first = false;
- } while ($repeatThis);
- }
- }
- return true;
-}
-
//Select Members
function getMembers($order, $pageNumber = 1, $pageDivide = 50) {
@@ -826,8 +756,8 @@ function getMembers($order, $pageNumber = 1, $pageDivide = 50) {
WHERE solutions.userID = users.ID AND
solutions.dateModified < CURRENT_DATE)
, 0) AS totalMazes,
- SUM(CASE WHEN statistics.type IN (32, 33, 34, 35) THEN statistics.value ELSE 0 END) as totalWins,
- SUM(CASE WHEN statistics.type IN (1, 2, 3, 4) THEN statistics.value ELSE 0 END) as totalTies,
+ users.totalWins,
+ users.totalTies,
IfNull(userData.wallColor, '#666666') as wallColor,
IfNull(userData.displayColor, '#cccccc'),
userData.wallEmblem as wallEmblem,
@@ -835,8 +765,6 @@ function getMembers($order, $pageNumber = 1, $pageDivide = 50) {
users.dateLogin as dateLogin
FROM `users`
LEFT JOIN `userData` ON users.ID = userData.userID
- LEFT JOIN `statistics` ON users.ID = statistics.userID
- GROUP BY users.ID
$order
LIMIT $limitTop, $pageDivide
";