mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-13404 - Minor performance improvement and code cleanup (merge from 1.9)
This commit is contained in:
parent
e17500c0fe
commit
844f9c150d
1 changed files with 8 additions and 5 deletions
13
tag/lib.php
13
tag/lib.php
|
@ -641,7 +641,6 @@ function tag_compute_correlations($min_correlation=2) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
$all_tags = get_records_list('tag');
|
$all_tags = get_records_list('tag');
|
||||||
|
|
||||||
|
|
||||||
$tag_correlation_obj = new object();
|
$tag_correlation_obj = new object();
|
||||||
foreach($all_tags as $tag) {
|
foreach($all_tags as $tag) {
|
||||||
|
@ -653,7 +652,7 @@ function tag_compute_correlations($min_correlation=2) {
|
||||||
"WHERE ta.tagid = {$tag->id} AND tb.tagid != {$tag->id} ".
|
"WHERE ta.tagid = {$tag->id} AND tb.tagid != {$tag->id} ".
|
||||||
"GROUP BY tb.tagid ".
|
"GROUP BY tb.tagid ".
|
||||||
"HAVING nr > $min_correlation ".
|
"HAVING nr > $min_correlation ".
|
||||||
"ORDER BY nr DESC"; // todo: find out if it's necessary to order.
|
"ORDER BY nr DESC";
|
||||||
|
|
||||||
$correlated = array();
|
$correlated = array();
|
||||||
|
|
||||||
|
@ -661,13 +660,17 @@ function tag_compute_correlations($min_correlation=2) {
|
||||||
// than $min_correlation.
|
// than $min_correlation.
|
||||||
if ($tag_correlations = get_records_sql($query)) {
|
if ($tag_correlations = get_records_sql($query)) {
|
||||||
foreach($tag_correlations as $correlation) {
|
foreach($tag_correlations as $correlation) {
|
||||||
// commented out - now done in query. kept here in case it breaks on some db
|
// commented out - now done in query. kept here in case it breaks on some db
|
||||||
// if($correlation->nr >= $min_correlation){
|
// if($correlation->nr >= $min_correlation){
|
||||||
$correlated[] = $correlation->tagid;
|
$correlated[] = $correlation->tagid;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($correlated)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$correlated = implode(',', $correlated);
|
$correlated = implode(',', $correlated);
|
||||||
//var_dump($correlated);
|
//var_dump($correlated);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue