<commit_before><?php

if($argc != 2)
{
	echo "Arguments missing.\n\n";
	echo "Usage: php removeOldEntries.php {days old}\n";
	exit;
} 
$daysOld = $argv[1];
$updatedAt = time() - ($daysOld * 24 * 60 * 60);

chdir(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../bootstrap.php');

$typesToDelete = array(
//	entryType::AUTOMATIC,
//	entryType::BACKGROUND,
//	entryType::MEDIA_CLIP,
//	entryType::SHOW,
//	entryType::BUBBLES,
//	entryType::PLAYLIST,
//	entryType::DATA,
//	entryType::LIVE_STREAM,
//	entryType::DOCUMENT,
//	entryType::DVD,
);

$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();

$c = new Criteria();
$c->add(entryPeer::PARTNER_ID, 100, Criteria::GREATER_THAN);
$c->add(entryPeer::UPDATED_AT, $updatedAt, Criteria::LESS_THAN);
if(count($typesToDelete))
	$c->add(entryPeer::TYPE, $typesToDelete, Criteria::IN);

$entries = entryPeer::doSelect($c);

foreach($entries as $entry)
{
	KalturaLog::debug("Deletes entry [" . $entry->getId() . "]");
	myEntryUtils::deleteEntry($entry, $entry->getPartnerId());
}
KalturaLog::debug("Done");
<commit_msg>qnd: added chunked run<commit_after><?php

if($argc < 2)
{
	echo "Arguments missing.\n\n";
	echo "Usage: php removeOldEntries.php {days old}\n";
	exit;
} 
$daysOld = $argv[1];
$dryRun = true;
if($argc > 2 && strtolower($argv[1]) == 'realrun')
	$dryRun = false;
	
$updatedAt = time() - ($daysOld * 24 * 60 * 60);

chdir(dirname(__FILE__));
require_once(dirname(__FILE__) . '/../bootstrap.php');

$typesToDelete = array(
//	entryType::AUTOMATIC,
//	entryType::BACKGROUND,
//	entryType::MEDIA_CLIP,
//	entryType::SHOW,
//	entryType::BUBBLES,
//	entryType::PLAYLIST,
//	entryType::DATA,
//	entryType::LIVE_STREAM,
//	entryType::DOCUMENT,
//	entryType::DVD,
);

$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();

$c = new Criteria();
$c->add(entryPeer::PARTNER_ID, 100, Criteria::GREATER_THAN);
$c->add(entryPeer::UPDATED_AT, $updatedAt, Criteria::LESS_THAN);
if(count($typesToDelete))
	$c->add(entryPeer::TYPE, $typesToDelete, Criteria::IN);
 
$count = 0;
$entries = entryPeer::doSelect($c);
while($entries)
{
	$count += count($entries);
	foreach($entries as $entry)
	{
		KalturaLog::debug("Deletes entry [" . $entry->getId() . "]");
		KalturaStatement::setDryRun($dryRun);
		myEntryUtils::deleteEntry($entry, $entry->getPartnerId());
		KalturaStatement::setDryRun(false);
	}
	kMemoryManager::clearMemory();
	$entries = entryPeer::doSelect($c);
}
KalturaLog::debug("Deleted [$count] entries");

{'fraction_non_alphanumeric': 0.21176003178386968, 'fraction_numerical': 0.009932459276916964, 'mean_word_length': 6.298550724637681, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7467595', 'n_tokens_mistral': 994, 'n_tokens_neox': 959, 'n_words': 151}