<commit_before><?php
/**
 * @package  newsletter
 */

/**
 * Adding this class to a {@link GridFieldConfig} of a {@link GridField} adds a header title with a summary of the
 * Status of the contained records
 */
class GridFieldNewsletterSummaryHeader implements GridField_HTMLProvider {
	public function getHTMLFragments( $gridField) {
		if ($gridField && $gridField->getModelClass() && $gridField->getModelClass() == "SendRecipientQueue") {
			$list = $gridField->getList();
			$scheduled = $list->filter(array('Status'=>'Scheduled'))->count();			
			$progress = $list->filter(array('Status'=>'InProgress'))->count();
			$sent = $list->filter(array('Status'=>'Sent'))->count();
			$failed = $list->filter(array('Status'=>array('Failed','Bounced','BlackListed')))->count();

			$statusText = '<span>'
				. _t('Newsletter.Scheduled', '{count} scheduled', array('count' => $scheduled))
				. '</span>'
				. '<span>'
				. _t('Newsletter.InProgress', '{count} in progress', array('count' => $progress)) 
				. '</span>'
				. '<span>'
				. _t('Newsletter.Sent', '{count} sent', array('count' => $sent)) 
				. '</span>'
				. '<span>'
				. _t('Newsletter.Failed', '{count} failed', array('count' => $failed)) 
				. '</span>';

			$gridField->StatusText = $statusText;

			return array(
				'header' => $gridField->renderWith('GridFieldNewsletterSummaryHeader')
			);
		}
	}
}<commit_msg>Don't show zero statuses in "sent to" summary<commit_after><?php
/**
 * @package  newsletter
 */

/**
 * Adding this class to a {@link GridFieldConfig} of a {@link GridField} adds a header title with a summary of the
 * Status of the contained records
 */
class GridFieldNewsletterSummaryHeader implements GridField_HTMLProvider {
	public function getHTMLFragments( $gridField) {
		if ($gridField && $gridField->getModelClass() && $gridField->getModelClass() == "SendRecipientQueue") {
			$list = $gridField->getList();

			$scheduled = $list->filter(array('Status'=>'Scheduled'))->count();			
			$progress = $list->filter(array('Status'=>'InProgress'))->count();
			$sent = $list->filter(array('Status'=>'Sent'))->count();
			$failed = $list->filter(array('Status'=>array('Failed','Bounced','BlackListed')))->count();

			$statuses = array();
			if($scheduled) {
				$statuses[] = _t('Newsletter.Scheduled', '{count} scheduled', array('count' => $scheduled));
			}
			if($progress) {
				$statuses[] = _t('Newsletter.InProgress', '{count} in progress', array('count' => $progress));
			}
			if($sent) {
				$statuses[] = _t('Newsletter.Sent', '{count} sent', array('count' => $sent));
			}
			if($failed) {
				$statuses[] = _t('Newsletter.Failed', '{count} failed', array('count' => $failed));
			}

			$gridField->StatusText = implode(', ', $statuses);

			return array(
				'header' => $gridField->renderWith('GridFieldNewsletterSummaryHeader')
			);
		}
	}
}
{'fraction_non_alphanumeric': 0.20687237026647967, 'fraction_numerical': 0.0, 'mean_word_length': 4.605108055009823, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 55, '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': '6537585', 'n_tokens_mistral': 1007, 'n_tokens_neox': 890, 'n_words': 183}