Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class myClass {
- private $tids=array();
- public $active_topics=array();
- public function __construct() {/* removed irrelevant code */}
- public function getTopicsScore($topics=false,$params=array()) {
- // removed irrelevant code
- $results = $this->getScores($this->tids,$params);
- $start = microtime(true);
- foreach($results as $r) {
- //removed irrelevant code
- if(!isset($this->active_topics[$r['topic_id']])) {
- $this->active_topics[$r['topic_id']] = array_merge(array('tid' => $r['topic_id']),$this->default_values);
- }
- $this->getPointsBasic($r);
- }
- echo round(microtime(true)-$start,4).' returned '.count();
- return $this->active_topics;
- }
- private function getPointsBasic($r) {
- $this->active_topics[$r['topic_id']]['d_score'] += $r['score'];
- $this->active_topics[$r['topic_id']]['d_'.$r['type']] += $r['score'];
- switch($r['type']) {
- case 'likes':
- $r['score'] *= 2.3;
- break;
- // more cases with different calculations etc....
- }
- $this->active_topics[$r['topic_id']][$r['type']] += $r['score'];
- $this->active_topics[$r['topic_id']]['total_score'] += $r['score'];
- }
- // removed irrelevant code
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement