Skip to content

Commit

Permalink
dev: speed up survey listing by not loading the model (show columns /…
Browse files Browse the repository at this point in the history
… create etc.)

dev: keep dbversion and update also on config after we load them saves extra db calls
  • Loading branch information
mennodekker committed Dec 13, 2012
1 parent 14cff6f commit 0801b36
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions application/helpers/globalsettings_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ function injectglobalsettings()
//foreach ($dbvaluearray as $setting)
foreach ($settings as $setting)
{
if (Yii::app()->getConfig($setting->getAttribute('stg_name')) !== false)
{
//if (Yii::app()->getConfig($setting->getAttribute('stg_name')) !== false)
//{
//$$setting['stg_name']=$setting['stg_value'];
Yii::app()->setConfig($setting->getAttribute('stg_name'), $setting->getAttribute('stg_value'));
}
//}
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions application/models/Survey_dynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ public function addTokenCriteria($condition)
return $newCriteria;
}

public static function countAllAndPartial($sid)
{
$select = array(
'count(*) AS cntAll',
'sum(CASE
WHEN submitdate IS NULL THEN 1
ELSE 0
END) AS cntPartial',
);
$result = Yii::app()->db->createCommand()->select($select)->from('{{survey_' . $sid . '}}')->queryRow();
return $result;
}

/**
* Return true if actual survey is completed
*
Expand Down
13 changes: 13 additions & 0 deletions application/models/Tokens_dynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,19 @@ function selectEmptyTokens($iSurveyID)
{
return Yii::app()->db->createCommand("SELECT tid FROM {{tokens_{$iSurveyID}}} WHERE token IS NULL OR token=''")->queryAll();
}

public static function countAllAndCompleted($sid)
{
$select = array(
'count(*) AS cntAll',
'sum(CASE completed
WHEN "Y" THEN 0
ELSE 1
END) AS cntCompleted',
);
$result = Yii::app()->db->createCommand()->select($select)->from('{{tokens_' . $sid . '}}')->queryRow();
return $result;
}

/**
* Creates and inserts token for a specific token record and returns the token string created
Expand Down

0 comments on commit 0801b36

Please sign in to comment.