Permalink
Browse files

switching the queries so we only calculate ratings for records we're …

…actually going to show, rather than all of them, as the performance hit is noticeable
  • Loading branch information...
1 parent f2eb94a commit 20b06930cc11e17e66c5738bafb29bde9580e613 @lornajane lornajane committed Apr 29, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/system/application/models/talks_model.php
@@ -249,7 +249,6 @@ public function getPopularTalks($len=7) {
t.talk_title,
t.ID,
count(tc.ID) as ccount,
- get_talk_rating(t.ID) as tavg,
e.ID eid,
e.event_name
from
@@ -273,6 +272,11 @@ public function getPopularTalks($len=7) {
$CI=&get_instance();
$CI->load->model('talk_speaker_model','tsm');
foreach ($talks as $k=>$talk) {
+ $sql = "select get_talk_rating(" . $talk->ID . ") as tavg";
+ $rating_result = $this->db->query($sql)->result();
+ $rating = $rating_result[0];
+ $talks[$k]->tavg = $rating->tavg;
+
$talks[$k]->speaker=$CI->tsm->getTalkSpeakers($talk->ID);
}
return $talks;

0 comments on commit 20b0693

Please sign in to comment.