<commit_before><?php
/**
 * @package Var
 * @subpackage Partners
 */
class PartnerUsageController extends Zend_Controller_Action
{
	public function indexAction()
	{
		
		$request = $this->getRequest();
		$page = $this->_getParam('page', 1);
		$pageSize = $this->_getParam('pageSize', 10);
		$from = new Zend_Date($this->_getParam('from_date', $this->getDefaultFromDate()));
		$to = new Zend_Date($this->_getParam('to_date', $this->getDefaultToDate()));
		
		$client = Infra_ClientHelper::getClient();
		
		$form = new Form_PartnerUsageFilter();
		
		$form->populate($request->getParams());
		
		// when no statuses selected
		if (!$form->getElement('include_active')->getValue() && !$form->getElement('include_blocked')->getValue() && !$form->getElement('include_removed')->getValue())
		{
			$form->getElement('include_active')->setValue(1);
			$form->getElement('include_blocked')->setValue(1);
			$form->getElement('include_removed')->setValue(1);
		}
		
		// init filters
		$usageFilter = new Kaltura_Client_Type_ReportInputFilter();
		$usageFilter->fromDate = $from->toString(Zend_Date::TIMESTAMP);
		$usageFilter->toDate = $to->toString(Zend_Date::TIMESTAMP);
		$partners = $client->partner->listAction();
		$partnerIds = array();
		
		foreach ($partners->objects as $partner)
		    $partnerIds[] = $partner->id;
		
		// get results and paginate
		$paginatorAdapter = new Infra_FilterPaginator($client->report, "getGraphs", null, Kaltura_Client_Enum_ReportType::PARTNER_USAGE, $usageFilter, null, $partnerIds);
		$paginator = new Infra_Paginator($paginatorAdapter, $request);
		$paginator->setCurrentPageNumber($page);
		$paginator->setItemCountPerPage($pageSize);
		// set view
		$this->view->from = $from;
		$this->view->to = $to;
		$this->view->form = $form;
		$this->view->paginator = $paginator;
	}
	
	public function exportCsvAction() 
	{
		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender();<commit_msg>fwr: use new service<commit_after><?php
/**
 * @package Var
 * @subpackage Partners
 */
class PartnerUsageController extends Zend_Controller_Action
{
	public function indexAction()
	{
		
		$request = $this->getRequest();
		$page = $this->_getParam('page', 1);
		$pageSize = $this->_getParam('pageSize', 10);
		$from = new Zend_Date($this->_getParam('from_date', $this->getDefaultFromDate()));
		$to = new Zend_Date($this->_getParam('to_date', $this->getDefaultToDate()));
		
		$client = Infra_ClientHelper::getClient();
		
		$form = new Form_PartnerUsageFilter();
		
		$form->populate($request->getParams());
		
		// when no statuses selected
		if (!$form->getElement('include_active')->getValue() && !$form->getElement('include_blocked')->getValue() && !$form->getElement('include_removed')->getValue())
		{
			$form->getElement('include_active')->setValue(1);
			$form->getElement('include_blocked')->setValue(1);
			$form->getElement('include_removed')->setValue(1);
		}
		
		// init filters
		
		$usageFilter = new Kaltura_Client_Type_ReportInputFilter();
		$usageFilter->fromDate = $from->toString(Zend_Date::TIMESTAMP);
		$usageFilter->toDate = $to->toString(Zend_Date::TIMESTAMP);
		
		$varConsolePlugin = Kaltura_Client_VarConsole_Plugin::get($client);
		
		// get results and paginate
		$partnerFilter = $this->getPartnerFilterFromForm($form);
		$paginatorAdapter = new Infra_FilterPaginator();
		$paginator = new Infra_Paginator($varConsolePlugin->varConsole, "getPartnerUsage", null, $partnerFilter, $usageFilter);
		$paginator->setCurrentPageNumber($page);
		$paginator->setItemCountPerPage($pageSize);
		// set view
		$this->view->from = $from;
		$this->view->to = $to;
		$this->view->form = $form;
		$this->view->paginator = $paginator;
	}
	
	public function exportCsvAction() 
	{
		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender();
{'fraction_non_alphanumeric': 0.17831074035453598, 'fraction_numerical': 0.0031282586027111575, 'mean_word_length': 5.547781569965871, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 92, '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': '5445304', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1215, 'n_words': 189}