<commit_before><?php

class Bundle_model extends Model {

	function __construct() {
		parent::Model();
	}



	function get_list() {
		$this->db->select('id, name');
		$this->db->from('bundles');
		$this->db->where('customer_id', $this->sess->customer_id);
		$this->db->order_by('name'); 
		$query = $this->db->get();
		
		if($query->num_rows() > 0) {
			foreach($query->result_array() as $row) {
				$data[$row['id']] = $row;
				unset($data[$row['id']]['id']);
			}
		} else {
			$data = array();
		}

		return $data;
	}



	function get_one($id = NULL) {
	
		$this->db->select('id, name');
		$this->db->from('bundles');
		$this->db->where('customer_id', $this->sess->customer_id);
		$this->db->where('id', $id);
		$this->db->limit(1);
		$query = $this->db->get();
		
		if($query->num_rows() > 0) {
			$data = $query->row_array();
		} else {
			foreach($query->field_data() as $row) {
				$data[$row->name] = NULL;
			}
		}
		
		return $data;
		
	}



	function get_name($id) {
		$this->db->select('name');
		$this->db->where('id', $id);
		$result = $this->db->get('bundles');
		
		if ($result->num_rows() > 0) return $result->row()->name;

	} 



	function get_names_list() {	
		$result = array();
		
		foreach($this->get_list() as $key => $value):
			$result[$key] = $value['name'];
		endforeach;
		
		return $result;
	} 



	function get_screens($bundle_id) {	
		$this->db->select('screens.id, screens.name');
		$this->db->from('screens');
		$this->db->join('collections_schedules', 'collections_schedules.schedule_id = screens.schedule_id', 'left');
		$this->db->join('layouts_collections', 'layouts_collections.collection_id = collections_schedules.collection_id', 'left');
		$this->db->join('bundles_layouts', 'bundles_layouts.layout_id = layouts_collections.layout_id', 'left');
		$this->db->where(array('bundles_layouts.bundle_id' => $bundle_id));
		$query = $this->db->get();
		
		if($query->num_rows() > 0) {
			foreach($query->result_array() as $row) {
				$data[$row['id']] = $row;
				//unset($data[$row['id']]['id']);
			}
		} else {
			$data = array();
		}

		return $data;
	} 



	function get_medias($bundle_id) {	
		$this->db->select('medias.id,
		                   medias.duration,
		                   medias.type,
		                   medias_bundles.frequency,
		                   medias_bundles.appearances,
		                   medias_bundles.importance,
		                   medias_bundles.probability,
		                   medias_bundles.valid_from_date,
		                   medias_bundles.valid_to_date');
		$this->db->from('medias');
		$this->db->join('medias_bundles', 'medias_bundles.media_id = medias.id', 'left');
		$this->db->where(array('medias_bundles.bundle_id' => $bundle_id));
		$query = $this->db->get();
		
		if($query->num_rows() > 0) {
			foreach($query->result_array() as $row) {
				$data[$row['id']] = $row;
				//unset($data[$row['id']]['id']);<commit_msg>Added audio_yn to playlist generation<commit_after><?php

class Bundle_model extends Model {

	function __construct() {
		parent::Model();
	}



	function get_list() {
		$this->db->select('id, name');
		$this->db->from('bundles');
		$this->db->where('customer_id', $this->sess->customer_id);
		$this->db->order_by('name'); 
		$query = $this->db->get();
		
		if($query->num_rows() > 0) {
			foreach($query->result_array() as $row) {
				$data[$row['id']] = $row;
				unset($data[$row['id']]['id']);
			}
		} else {
			$data = array();
		}

		return $data;
	}



	function get_one($id = NULL) {
	
		$this->db->select('id, name');
		$this->db->from('bundles');
		$this->db->where('customer_id', $this->sess->customer_id);
		$this->db->where('id', $id);
		$this->db->limit(1);
		$query = $this->db->get();
		
		if($query->num_rows() > 0) {
			$data = $query->row_array();
		} else {
			foreach($query->field_data() as $row) {
				$data[$row->name] = NULL;
			}
		}
		
		return $data;
		
	}



	function get_name($id) {
		$this->db->select('name');
		$this->db->where('id', $id);
		$result = $this->db->get('bundles');
		
		if ($result->num_rows() > 0) return $result->row()->name;

	} 



	function get_names_list() {	
		$result = array();
		
		foreach($this->get_list() as $key => $value):
			$result[$key] = $value['name'];
		endforeach;
		
		return $result;
	} 



	function get_screens($bundle_id) {	
		$this->db->select('screens.id, screens.name');
		$this->db->from('screens');
		$this->db->join('collections_schedules', 'collections_schedules.schedule_id = screens.schedule_id', 'left');
		$this->db->join('layouts_collections', 'layouts_collections.collection_id = collections_schedules.collection_id', 'left');
		$this->db->join('bundles_layouts', 'bundles_layouts.layout_id = layouts_collections.layout_id', 'left');
		$this->db->where(array('bundles_layouts.bundle_id' => $bundle_id));
		$query = $this->db->get();
		
		if($query->num_rows() > 0) {
			foreach($query->result_array() as $row) {
				$data[$row['id']] = $row;
				//unset($data[$row['id']]['id']);
			}
		} else {
			$data = array();
		}

		return $data;
	} 



	function get_medias($bundle_id) {	
		$this->db->select('medias.id,
		                   medias.duration,
		                   medias.type,
		                   medias_bundles.frequency,
		                   medias_bundles.appearances,
		                   medias_bundles.importance,
		                   medias_bundles.probability,
		                   medias_bundles.valid_from_date,
		                   medias_bundles.valid_to_date,
		                   medias_bundles.audio_yn');
		$this->db->from('medias');
		$this->db->join('medias_bundles', 'medias_bundles.media_id = medias.id', 'left');
		$this->db->where(array('medias_bundles.bundle_id' => $bundle_id));
		$query = $this->db->get();
		
		if($query->num_rows() > 0) {
			foreach($query->result_array() as $row) {
				$data[$row['id']] = $row;
				//unset($data[$row['id']]['id']);
{'fraction_non_alphanumeric': 0.21598639455782312, 'fraction_numerical': 0.0020408163265306124, 'mean_word_length': 3.182788051209104, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 159, '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': '117911', 'n_tokens_mistral': 2453, 'n_tokens_neox': 2113, 'n_words': 290}