public function test_getActionReferenceColumnsByTable_AppliesOverrideColumnsCorrectly_WithoutAllowingDuplicates()
 {
     $dimensionMetadataProvider = new DimensionMetadataProvider(array('log_link_visit_action' => array('idaction_url', 'idaction_event_category'), 'log_conversion' => array(), 'log_conversion_item' => array('some_unknown_idaction_column'), 'log_custom_table' => array('some_column1', 'some_column2')));
     $actualColumns = $dimensionMetadataProvider->getActionReferenceColumnsByTable();
     $expectedColumns = array('log_link_visit_action' => array('idaction_url', 'idaction_url_ref', 'idaction_name_ref', 'idaction_event_action', 'idaction_event_category', 'idaction_name', 'idaction_content_interaction', 'idaction_content_name', 'idaction_content_piece', 'idaction_content_target'), 'log_conversion' => array('idaction_url'), 'log_visit' => array('visit_exit_idaction_url', 'visit_exit_idaction_name', 'visit_entry_idaction_url', 'visit_entry_idaction_name'), 'log_conversion_item' => array('idaction_sku', 'idaction_name', 'idaction_category', 'idaction_category2', 'idaction_category3', 'idaction_category4', 'idaction_category5', 'some_unknown_idaction_column'), 'log_custom_table' => array('some_column1', 'some_column2'));
     $this->assertEquals($expectedColumns, $actualColumns);
 }
Example #2
0
 protected function insertActionsToKeep($maxIds, $olderThan = true, $insertIntoTempIterationStep = 100000)
 {
     $tempTableName = Common::prefixTable(self::DELETE_UNUSED_ACTIONS_TEMP_TABLE_NAME);
     $idColumns = $this->getTableIdColumns();
     foreach ($this->dimensionMetadataProvider->getActionReferenceColumnsByTable() as $table => $columns) {
         $idCol = $idColumns[$table];
         foreach ($columns as $col) {
             $select = "SELECT {$col} FROM " . Common::prefixTable($table) . " WHERE {$idCol} >= ? AND {$idCol} < ?";
             $sql = "INSERT IGNORE INTO {$tempTableName} {$select}";
             if ($olderThan) {
                 $start = 0;
                 $finish = $maxIds[$table];
             } else {
                 $start = $maxIds[$table];
                 $finish = Db::fetchOne("SELECT MAX({$idCol}) FROM " . Common::prefixTable($table));
             }
             Db::segmentedQuery($sql, $start, $finish, $insertIntoTempIterationStep);
         }
     }
 }