Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/categories/categories_event_handler.php
Show First 20 Lines • Show All 2758 Lines • ▼ Show 20 Line(s) | |||||
if ($rel_pop && $object->isField('Hits')) { | if ($rel_pop && $object->isField('Hits')) { | ||||
$relevance_clause .= ' + (Hits + 1) / (MAX(Hits) + 1) * '.$rel_pop; | $relevance_clause .= ' + (Hits + 1) / (MAX(Hits) + 1) * '.$rel_pop; | ||||
} | } | ||||
if ($rel_rating && $object->isField('CachedRating')) { | if ($rel_rating && $object->isField('CachedRating')) { | ||||
$relevance_clause .= ' + (CachedRating + 1) / (MAX(CachedRating) + 1) * '.$rel_rating; | $relevance_clause .= ' + (CachedRating + 1) / (MAX(CachedRating) + 1) * '.$rel_rating; | ||||
} | } | ||||
// building final search query | // building final search query | ||||
$search_table_exists = $this->Conn->Query('SHOW TABLES LIKE "'.$search_table.'"'); | |||||
if (!$this->Application->GetVar('do_not_drop_search_table')) { | if (!$this->Application->GetVar('do_not_drop_search_table')) { | ||||
$this->Conn->Query('DROP TABLE IF EXISTS '.$search_table); // erase old search table if clean k4 event | if ( $search_table_exists ) { | ||||
$this->Conn->Query('TRUNCATE TABLE '.$search_table); | |||||
} | |||||
$this->Application->SetVar('do_not_drop_search_table', true); | $this->Application->SetVar('do_not_drop_search_table', true); | ||||
} | } | ||||
$search_table_exists = $this->Conn->Query('SHOW TABLES LIKE "'.$search_table.'"'); | |||||
if ($search_table_exists) { | if ($search_table_exists) { | ||||
$select_intro = 'INSERT INTO '.$search_table.' (Relevance, ItemId, ResourceId, ItemType, EdPick) '; | $select_intro = 'INSERT INTO '.$search_table.' (Relevance, ItemId, ResourceId, ItemType, EdPick) '; | ||||
} | } | ||||
else { | else { | ||||
$select_intro = 'CREATE TABLE '.$search_table.' AS '; | $select_intro = 'CREATE TABLE '.$search_table.' ENGINE = MEMORY AS '; | ||||
} | } | ||||
$edpick_clause = $this->Application->getUnitOption($event->Prefix.'.EditorsPick', 'Fields') ? $items_table.'.EditorsPick' : '0'; | $edpick_clause = $this->Application->getUnitOption($event->Prefix.'.EditorsPick', 'Fields') ? $items_table.'.EditorsPick' : '0'; | ||||
$sql = $select_intro.' SELECT '.$relevance_clause.' AS Relevance, | $sql = $select_intro.' SELECT '.$relevance_clause.' AS Relevance, | ||||
'.$items_table.'.'.$this->Application->getUnitOption($event->Prefix, 'IDField').' AS ItemId, | '.$items_table.'.'.$this->Application->getUnitOption($event->Prefix, 'IDField').' AS ItemId, | ||||
'.$items_table.'.ResourceId, | '.$items_table.'.ResourceId, | ||||
'.$this->Application->getUnitOption($event->Prefix, 'ItemType').' AS ItemType, | '.$this->Application->getUnitOption($event->Prefix, 'ItemType').' AS ItemType, | ||||
▲ Show 20 Lines • Show All 442 Lines • Show Last 20 Lines |