Permalink
Browse files

Merge branch 'MDL-24355_emergency_20' of git://github.com/stronk7/moo…

…dle into MOODLE_20_STABLE
  • Loading branch information...
2 parents 06c09f3 + 75454e2 commit 85a91fb98e8e36bda09b38c4ba9df679890b5abd @skodak skodak committed Apr 13, 2011
Showing with 11 additions and 10 deletions.
  1. +11 −10 tag/lib.php
View
@@ -831,16 +831,17 @@ function tag_compute_correlations($mincorrelation = 2) {
// correlationid : This is the id of the row in the tag_correlation table that
// relates to the tagid field and will be NULL if there are no
// existing correlations
- $sql = 'SELECT ta.tagid, tb.tagid AS correlation, co.id AS correlationid, co.correlatedtags
- FROM {tag_instance} ta
- LEFT JOIN {tag_instance} tb
- ON (ta.itemtype = tb.itemtype AND ta.itemid = tb.itemid AND ta.tagid <> tb.tagid)
- LEFT JOIN {tag_correlation} co
- ON co.tagid = ta.tagid
- WHERE tb.tagid IS NOT NULL
- GROUP BY ta.tagid, tb.tagid
- HAVING COUNT(*) > :mincorrelation
- ORDER BY ta.tagid ASC, COUNT(*) DESC, tb.tagid ASC';
+ $sql = 'SELECT pairs.tagid, pairs.correlation, pairs.ocurrences,
+ co.id AS correlationid, co.correlatedtags
+ FROM (
+ SELECT ta.tagid, tb.tagid AS correlation, COUNT(*) AS ocurrences
+ FROM {tag_instance} ta
+ JOIN {tag_instance} tb ON (ta.itemtype = tb.itemtype AND ta.itemid = tb.itemid AND ta.tagid <> tb.tagid)
+ GROUP BY ta.tagid, tb.tagid
+ HAVING COUNT(*) > :mincorrelation
+ ) pairs
+ LEFT JOIN {tag_correlation} co ON co.tagid = pairs.tagid
+ ORDER BY pairs.tagid ASC, pairs.ocurrences DESC, pairs.correlation ASC';
$rs = $DB->get_recordset_sql($sql, array('mincorrelation' => $mincorrelation));
// Set up an empty tag correlation object

0 comments on commit 85a91fb

Please sign in to comment.