protected function CooccurrenceRecommender::computeSimilarityDatabase in Recommender API 6.2
Overrides Recommender::computeSimilarityDatabase
1 call to CooccurrenceRecommender::computeSimilarityDatabase()
File
- ./
Recommender.php, line 665
Class
- CooccurrenceRecommender
- The simple co-occurrence algorithm
Code
protected function computeSimilarityDatabase() {
watchdog("recommender", "Computing similarity in database. Might take a long time. Please be patient.");
if ($this->fieldWeight === NULL) {
$count = "COUNT(*)";
// if no $fieldWeight is specified, just count the occurrences.
}
else {
// otherwise, use the weight.
$count = "SUM((n1.{$this->fieldWeight}+n2.{$this->fieldWeight})/2)";
}
$sql = "INSERT INTO {recommender_similarity}(app_id, mouse1_id, mouse2_id, similarity, created)\n SELECT {$this->appId}, n1.{$this->fieldMouse}, n2.{$this->fieldMouse}, {$count}, {$this->created}\n FROM {{$this->tableName}} n1 INNER JOIN {{$this->tableName}} n2 ON n1.{$this->fieldCheese}=n2.{$this->fieldCheese}\n GROUP BY n1.{$this->fieldMouse}, n2.{$this->fieldMouse}";
update_sql($sql);
$this
->purgeOutdatedRecords('similarity');
}