From ab10ecccfd87825cfd5983d1e3fa1b701da4822c Mon Sep 17 00:00:00 2001 From: Anon Ray Date: Mon, 26 Dec 2011 15:59:48 +0530 Subject: [PATCH] Added more charts according to asana Added provision for adding combination charts --- Db.php | 19 +++++++++++++++++++ sudokuquest.php | 6 +++--- templates/index.html | 20 ++++++++++++++++++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/Db.php b/Db.php index b2712f7..84eceac 100644 --- a/Db.php +++ b/Db.php @@ -102,6 +102,7 @@ public function getCharts() public function getPayingUsers() { + $this->db_connect(); $q1 = "SELECT DISTINCT uid FROM credits"; $res = mysql_query($q1, $this->connfb); while($row = mysql_fetch_array($res, MYSQL_ASSOC)) @@ -112,6 +113,24 @@ public function getPayingUsers() return $uids; } + public function payingUsersLTVQuery() + { + $this->db_connect(); + $query = "SELECT gold, SUM(amount) as LTV, credits.uid, country, gender, source, DATE(starttime), DATE(lasttime), max_milestone FROM " + ."credits, user_info, user_game WHERE credits.uid=user_info.uid AND credits.uid=user_game.uid GROUP BY uid ORDER BY LTV DESC"; + $res = mysql_query($query, $this->connfb); + $data = array(); + $i = 0; + while($row = mysql_fetch_array($res, MYSQL_ASSOC)) + { + foreach($row as $key=>$value){ + $data[$i][$key] = $value; + } + $i++; + } + return $data; + } + public function executeQuery($query, $id) { if($id == '800') { diff --git a/sudokuquest.php b/sudokuquest.php index 19e307e..a0b9f1d 100644 --- a/sudokuquest.php +++ b/sudokuquest.php @@ -4,7 +4,8 @@ require_once('Utils.php'); $db = Db::getInstance(); -$ids = "100,200,290,5,300,320,330,350,400,500,520,550,570,580,610,620,630,640,650,700,800"; +$ids = "100,200,290,5,300,320,330,350,400,500,520,550,570,580,610,620,630,640,650,660,700,800,900"; +$LTV_data = $db->payingUsersLTVQuery(); $data = $db->getSpecificCharts($ids); /* specifying for which charts missing dates are to be filled */ @@ -23,7 +24,6 @@ $data = Utils::formatDates($data); $json_data = json_encode($data, JSON_NUMERIC_CHECK); -//echo "
"; print_r($data); echo "
"; +//echo "
"; print_r($LTV_data); echo "
"; require_once('templates/index.html'); - ?> diff --git a/templates/index.html b/templates/index.html index d69a544..dc65776 100644 --- a/templates/index.html +++ b/templates/index.html @@ -28,6 +28,7 @@ -