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);
- $local_topics=array();
- $start = microtime(true);
- foreach($results as $r) {
- //removed irrelevant code
- if(!isset($local_topics[$r['topic_id']])) {
- $local_topics[$r['topic_id']] = array_merge(array('tid' => $r['topic_id']),$this->default_values);
- }
- $local_topics[$r['topic_id']] = $this->getPointsBasic($r,$local_topics[$r['topic_id']]);
- }
- echo round(microtime(true)-$start,4);
- $this->active_topics=$local_topics;
- return $this->active_topics;
- }
- private function getPointsBasic($r,$t) {
- $t['d_score'] += $r['score'];
- $t['d_'.$r['type']] += $r['score'];
- switch($r['type']) {
- case 'likes':
- $r['score'] *= 2.3;
- break;
- // more cases with different calculations etc....
- }
- $t[$r['type']] += $r['score'];
- $t['total_score'] += $r['score'];
- return $t;
- }
- // removed irrelevant code
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement