<commit_before><?php 

include_once("BaseRepository.php");

class BloqueRepository extends BaseRepository{

	public function all( ){
		
		$blocks = new stdClass();

		$query = $this->pdo->prepare('SELECT b.id, b.name, b.empresa_id, b.enviado, e.nombre AS \'empresa\' FROM bloques b INNER JOIN empresa e ON b.empresa_id = e.id_empresa WHERE b.enviado = 0;');
		
		if($query->execute()){
			$blocks->exito = true;
			$blocks->rows = ( $query->rowCount() > 0 ) ? $query->fetchAll( \PDO::FETCH_ASSOC) : 'No se encontraron bloques';
			$blocks->error = 0;
		}else{
			$blocks->exito = false;
			$blocks->error = $query->errorInfo();
		}

		return $blocks;
	}

	public function getBlockById( $id ){
		
		$blocks = new stdClass();

		$query = $this->pdo->prepare('SELECT b.id, b.name, b.empresa_id, b.enviado, e.nombre AS \'empresa\' FROM bloques b INNER JOIN empresa e ON b.empresa_id = e.id_empresa WHERE b.enviado = 0 AND b.id = ' . $id);
		
		if($query->execute()){
			$blocks->exito = true;
			$blocks->rows = ( $query->rowCount() > 0 ) ? $query->fetch( \PDO::FETCH_ASSOC) : 'No se encontro el bloque';
			$blocks->error = 0;
		}else{
			$blocks->exito = false;
			$blocks->error = $query->errorInfo();
		}

		return $blocks;
	}

	public function getNewsOfBlock( $blockId ){
		
		$blocks = new stdClass();

		$sql = 'SELECT b.name, bn.noticia_id AS noticiaId, n.encabezado, n.sintesis, bn.tema_id AS temaId, t.nombre AS tema FROM bloques_noticias bn INNER JOIN bloques b ON bn.bloque_id = b.id INNER JOIN noticia n ON bn.noticia_id = n.id_noticia INNER JOIN tema t ON bn.tema_id = t.id_tema WHERE bn.bloque_id = :blockId;			
		';

		$query = $this->pdo->prepare( $sql );<commit_msg>Se modifica el query que obtiene las noticias de cada bloque para que muestre la fuente de la noticia obtenida y el id de bloque_noticia<commit_after><?php 

include_once("BaseRepository.php");

class BloqueRepository extends BaseRepository{

	public function all( ){
		
		$blocks = new stdClass();

		$query = $this->pdo->prepare('SELECT b.id, b.name, b.empresa_id, b.enviado, e.nombre AS \'empresa\' FROM bloques b INNER JOIN empresa e ON b.empresa_id = e.id_empresa WHERE b.enviado = 0;');
		
		if($query->execute()){
			$blocks->exito = true;
			$blocks->rows = ( $query->rowCount() > 0 ) ? $query->fetchAll( \PDO::FETCH_ASSOC) : 'No se encontraron bloques';
			$blocks->error = 0;
		}else{
			$blocks->exito = false;
			$blocks->error = $query->errorInfo();
		}

		return $blocks;
	}

	public function getBlockById( $id ){
		
		$blocks = new stdClass();

		$query = $this->pdo->prepare('SELECT b.id, b.name, b.empresa_id, b.enviado, e.nombre AS \'empresa\' FROM bloques b INNER JOIN empresa e ON b.empresa_id = e.id_empresa WHERE b.enviado = 0 AND b.id = ' . $id);
		
		if($query->execute()){
			$blocks->exito = true;
			$blocks->rows = ( $query->rowCount() > 0 ) ? $query->fetch( \PDO::FETCH_ASSOC) : 'No se encontro el bloque';
			$blocks->error = 0;
		}else{
			$blocks->exito = false;
			$blocks->error = $query->errorInfo();
		}

		return $blocks;
	}

	public function getNewsOfBlock( $blockId ){
		
		$blocks = new stdClass();

		$sql = 'SELECT bn.id AS bnid, b.name, bn.noticia_id AS noticiaId, n.encabezado, n.sintesis, f.nombre AS fuente, bn.tema_id AS temaId, t.nombre AS tema FROM bloques_noticias bn INNER JOIN bloques b ON bn.bloque_id = b.id INNER JOIN noticia n ON bn.noticia_id = n.id_noticia INNER JOIN fuente f ON n.id_fuente = f.id_fuente INNER JOIN tema t ON bn.tema_id = t.id_tema WHERE bn.bloque_id = :blockId;			
		';

		$query = $this->pdo->prepare( $sql );
{'fraction_non_alphanumeric': 0.15391084945332212, 'fraction_numerical': 0.00336417157275021, 'mean_word_length': 3.6157826649417855, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5309934', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1358, 'n_words': 357}