Skip to content

Commit

Permalink
dev: and now for pgsql too :)
Browse files Browse the repository at this point in the history
  • Loading branch information
mennodekker committed Dec 13, 2012
1 parent 4d7977c commit 0ba6f40
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions application/controllers/admin/surveyadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,8 @@ public function getSurveys_json()
if ($rows['active'] == "Y")
{
$cntResult = Survey_dynamic::countAllAndPartial($rows['sid']);
$all = $cntResult['cntAll'];
$partial = $cntResult['cntPartial'];
$all = $cntResult['cntall'];
$partial = $cntResult['cntpartial'];

$aSurveyEntry[] = $all - $partial;
$aSurveyEntry[] = $partial;
Expand All @@ -686,8 +686,8 @@ public function getSurveys_json()
if (tableExists('tokens_' . $rows['sid'] ))
{
$cntResult = Tokens_dynamic::countAllAndCompleted($rows['sid']);
$tokens = $cntResult['cntAll'];
$tokenscompleted = $cntResult['cntCompleted'];
$tokens = $cntResult['cntall'];
$tokenscompleted = $cntResult['cntcompleted'];

$aSurveyEntry[] = $tokens;
$aSurveyEntry[] = ($tokens == 0) ? 0 : round($tokenscompleted / $tokens * 100, 1);
Expand Down
4 changes: 2 additions & 2 deletions application/models/Survey_dynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ public function addTokenCriteria($condition)
public static function countAllAndPartial($sid)
{
$select = array(
'count(*) AS cntAll',
'count(*) AS cntall',
'sum(CASE
WHEN '. Yii::app()->db->quoteColumnName('submitdate') . ' IS NULL THEN 1
ELSE 0
END) AS cntPartial',
END) AS cntpartial',
);
$result = Yii::app()->db->createCommand()->select($select)->from('{{survey_' . $sid . '}}')->queryRow();
return $result;
Expand Down
4 changes: 2 additions & 2 deletions application/models/Tokens_dynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ function selectEmptyTokens($iSurveyID)
public static function countAllAndCompleted($sid)
{
$select = array(
'count(*) AS cntAll',
'count(*) AS cntall',
'sum(CASE '. Yii::app()->db->quoteColumnName('completed') . '
WHEN '.Yii::app()->db->quoteValue('Y').' THEN 0
ELSE 1
END) AS cntCompleted',
END) AS cntcompleted',
);
$result = Yii::app()->db->createCommand()->select($select)->from('{{tokens_' . $sid . '}}')->queryRow();
return $result;
Expand Down

0 comments on commit 0ba6f40

Please sign in to comment.