<commit_before><?php
namespace Dashboard\Model\Dao;

use Dashboard\Model\Dao\Exception\EndpointUrlNotAssembled;

/**
 * Class HipChatDao
 *
 * @package Dashboard\Model\Dao
 */
class HipChatDao extends AbstractDao
{
    /**
     * Fetch HipChat messages
     *
     * @param  array $params Params
     * @return array
     */
    public function fetchListRecentMessagesForMessagesWidget(array $params = array())
    {
        if (!isset($params['room'])) {
            throw new EndpointUrlNotAssembled('You need to specify room name');
        }

        $daoParams = $this->getDaoParams();
        $hipChatJson = $this->request($this->config['urls']['listRecentMessages'], array(
            'room_id' => $params['room'],
            'auth_token' => $daoParams['auth_token'],
        ), 'json', true);

        if ($hipChatJson && isset($hipChatJson['messages'])) {
            $returnArray = array();
            foreach (array_reverse($hipChatJson['messages']) as $message) {
                if (isset($params['fromUser'])) {
                    if (!is_array($params['fromUser'])) {
                        $params['fromUser'] = array($params['fromUser']);
                    }

                    if (in_array($message['from']['name'], $params['fromUser'])) {
                        $returnArray[] = array(
                            'projectName' => $message['from']['name'],
                            'createdAt' => (new \DateTime($message['date']))->format('Y-m-d H:i:s'),
                            'content' => $message['message'],
                        );
                    }
                } else {
                    $returnArray[] = array(
                        'projectName' => $message['from']['name'],
                        'createdAt' => (new \DateTime($message['date']))->format('Y-m-d H:i:s'),
                        'content' => $message['message'],
                    );
                }
            }

            return array_slice($returnArray, 0, $params['limit']);
        } else {
            return array();
        }
    }
}
<commit_msg>Adding basic stripping chars from hipchat message<commit_after><?php
namespace Dashboard\Model\Dao;

use Dashboard\Model\Dao\Exception\EndpointUrlNotAssembled;

/**
 * Class HipChatDao
 *
 * @package Dashboard\Model\Dao
 */
class HipChatDao extends AbstractDao
{
    private $stripChars = array('\n');

    /**
     * Fetch HipChat messages
     *
     * @param  array $params Params
     * @return array
     */
    public function fetchListRecentMessagesForMessagesWidget(array $params = array())
    {
        if (!isset($params['room'])) {
            throw new EndpointUrlNotAssembled('You need to specify room name');
        }

        $daoParams = $this->getDaoParams();
        $hipChatJson = $this->request($this->config['urls']['listRecentMessages'], array(
            'room_id' => $params['room'],
            'auth_token' => $daoParams['auth_token'],
        ), 'json', true);

        if ($hipChatJson && isset($hipChatJson['messages'])) {
            $returnArray = array();
            foreach (array_reverse($hipChatJson['messages']) as $message) {
                if (isset($params['fromUser'])) {
                    if (!is_array($params['fromUser'])) {
                        $params['fromUser'] = array($params['fromUser']);
                    }

                    if (in_array($message['from']['name'], $params['fromUser'])) {
                        $returnArray[] = array(
                            'projectName' => $message['from']['name'],
                            'createdAt' => (new \DateTime($message['date']))->format('Y-m-d H:i:s'),
                            'content' => str_replace($this->stripChars, '',$message['message']),
                        );
                    }
                } else {
                    $returnArray[] = array(
                        'projectName' => $message['from']['name'],
                        'createdAt' => (new \DateTime($message['date']))->format('Y-m-d H:i:s'),
                        'content' => str_replace($this->stripChars, '',$message['message']),
                    );
                }
            }

            return array_slice($returnArray, 0, $params['limit']);
        } else {
            return array();
        }
    }
}

{'fraction_non_alphanumeric': 0.16157407407407406, 'fraction_numerical': 0.000462962962962963, 'mean_word_length': 1.7504774029280712, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '10413', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1119, 'n_words': 199}