View difference between Paste ID: RyYNJCUH and TYU1rHwU
SHOW: | | - or go back to the newest paste.
1
<?php
2
class myClass {
3
4
	private $tids=array();
5-
	public function __construct() { /* removed irrelevant code */ }
5+
6
	
7
	public function __construct() {/* removed irrelevant code */}
8
	
9
	public function getTopicsScore($topics=false,$params=array()) {
10
		
11-
		$local_topics=array();
11+
12
		$results = $this->getScores($this->tids,$params);
13
		$start = microtime(true);
14
		
15
		foreach($results as $r) {
16
			//removed irrelevant code
17-
				$local_topics[$r['topic_id']] = array_merge(array('tid' => $r['topic_id']),$this->default_values);
17+
18
				$this->active_topics[$r['topic_id']] = array_merge(array('tid' => $r['topic_id']),$this->default_values);
19
			}
20-
			$local_topics[$r['topic_id']] = $this->getPointsBasic($r,$local_topics[$r['topic_id']]);
20+
21
			$this->getPointsBasic($r);
22-
		echo round(microtime(true)-$start,4);
22+
23-
		$this->active_topics=$local_topics;
23+
		echo round(microtime(true)-$start,4).' returned '.count();
24
		
25
		return $this->active_topics;
26
	}
27-
	private function getPointsBasic($r,$t) {
27+
28
	private function getPointsBasic($r) {
29-
		$t['d_score'] 		+= $r['score'];
29+
30-
		$t['d_'.$r['type']] += $r['score'];
30+
		$this->active_topics[$r['topic_id']]['d_score'] 		+= $r['score'];
31
		$this->active_topics[$r['topic_id']]['d_'.$r['type']] += $r['score'];
32
33
		switch($r['type']) {
34
			case 'likes':
35
				$r['score'] *= 2.3;
36
			break;
37
			
38
			//  more cases with different calculations etc....
39
		}
40-
		$t[$r['type']] 		+= $r['score'];
40+
41-
		$t['total_score'] 	+= $r['score'];
41+
		$this->active_topics[$r['topic_id']][$r['type']] 		+= $r['score'];
42
		$this->active_topics[$r['topic_id']]['total_score'] 	+= $r['score'];
43-
		return $t;
43+
44
	// removed irrelevant code
45
}