public function run($jobs = null) { KalturaLog::info("Running tag resolver"); $tagPlugin = KalturaTagSearchClientPlugin::get(self::$kClient); $deletedTags = $tagPlugin->tag->deletePending(); KalturaLog::info("Finished resolving tags: {$deletedTags} tags removed from DB"); }
protected function reIndexTags(KalturaBatchJob $job) { KalturaLog::info("Re-indexing tags according to privacy contexts"); $tagPlugin = KalturaTagSearchClientPlugin::get(self::$kClient); $this->impersonate($job->partnerId); try { $tagPlugin->tag->indexCategoryEntryTags($job->data->changedCategoryId, $job->data->deletedPrivacyContexts, $job->data->addedPrivacyContexts); } catch (Exception $e) { $this->unimpersonate(); return $this->closeJob($job, KalturaBatchJobErrorTypes::KALTURA_API, $e->getCode(), $e->getMessage(), KalturaBatchJobStatus::FAILED); } $this->unimpersonate(); return $this->closeJob($job, null, null, "Re-index complete", KalturaBatchJobStatus::FINISHED); }
/** * * Check whether when searching tags receive expected results * @param array $tagsToAdd * @param array $tagsToSearch * @param array $expectedResults * @dataProvider provideData */ public function testAdvancedSearch(array $tagsToAdd, array $tagsToSearch, array $expectedResults) { $entry = new KalturaBaseEntry(); $entry->name = "entry_testAdSearch"; foreach ($tagsToAdd as $tagToAdd) { if ($entry->tags && $entry->tags != "") { $entry->tags .= "," . $tagToAdd; } else { $entry->tags .= $tagToAdd; } } $this->client->baseEntry->add($entry); $tagClient = KalturaTagSearchClientPlugin::get($this->client); foreach ($tagsToSearch as $index => $tagToSearch) { try { $tagFilter = new KalturaTagFilter(); $tagFilter->objectTypeEqual = KalturaTaggedObjectType::ENTRY; $tagFilter->tagStartsWith = $tagToSearch; $searchResult = $tagClient->tag->search($tagFilter); } catch (Exception $e) { if ($e->getCode() == "PROPERTY_VALIDATION_MIN_LENGTH") { $this->assertEquals("error", $expectedResults[$index]); return; } } $this->assertEquals($expectedResults[$index], $searchResult->totalCount); } }