<commit_before><?php // if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require(APPPATH.'/libraries/REST_Controller.php');

class Groups extends REST_Controller {
    
    function __construct() {
        parent::__construct();
        // Autoloaded Config, Helpers, Models
        if ( !$this->session->userdata('email') ) {
            echo "Failed: Unauthorized access";
            exit();
        }
    }

    // Used to create a new group in the DB
    public function index_post() {
        $data = $this->post();
        
        $new_group = array( 
                'title'     => isset($data['group_title'])     ? $data['group_title']     : '' ,
                'entity'    => isset($data['group_entity'])    ? $data['group_entity']    : '' ,
                'entity_id' => isset($data['group_entity_id']) ? $data['group_entity_id'] : '' ,
                'is_plot'   => isset($data['group_is_plot'])   ? $data['group_is_plot']   : '' ,
                'is_number' => isset($data['group_is_number']) ? $data['group_is_number'] : ''  ); 
        
        $group_id = $this->group->create( $new_group );

        foreach ( $data['group_queries'] as $html_id => $query ) {
            $new_query = array(
                    'title'     => isset($query['query_title'])    ? $query['query_title']    : '' ,
                    'group_id'  => isset($group_id)                ? $group_id                : '' ,
                    'query_qb'  => isset($query['query_query_qb']) ? $query['query_query_qb'] : '' ,
                    'query_bz'  => isset($query['query_query_bz']) ? $query['query_query_bz'] : '' ,
                    'colour'    => isset($query['query_colour'])   ? $query['query_colour']   : ''  );
            
            $query_id = $this->query->create( $new_query );

            if ( isset($query['ref_version']) ) {
                if ( $query['ref_version'] != 'none' ) {
                    $query_version = $query_id . ',' . $query['ref_version'];
                    $new_reference = array(
                        'title'     => isset($query['query_title']) ? $query['query_title'].' ref. <version_title>'    : '' ,
                        'group_id'  => isset($group_id)             ? $group_id                : '' ,
                        'colour'    => isset($query['ref_colour'])  ? $query['ref_colour']     : '' ,
                        'references'=> $query_version  );

                    $ref_id = $this->query->create( $new_reference );
                }
            }
        }<commit_msg>Insert empty value to prevent null value in database<commit_after><?php // if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require(APPPATH.'/libraries/REST_Controller.php');

class Groups extends REST_Controller {
    
    function __construct() {
        parent::__construct();
        // Autoloaded Config, Helpers, Models
        if ( !$this->session->userdata('email') ) {
            echo "Failed: Unauthorized access";
            exit();
        }
    }

    // Used to create a new group in the DB
    public function index_post() {
        $data = $this->post();
        
        $new_group = array( 
                'title'     => isset($data['group_title'])     ? $data['group_title']     : '' ,
                'entity'    => isset($data['group_entity'])    ? $data['group_entity']    : '' ,
                'entity_id' => isset($data['group_entity_id']) ? $data['group_entity_id'] : '' ,
                'is_plot'   => isset($data['group_is_plot'])   ? $data['group_is_plot']   : '' ,
                'is_number' => isset($data['group_is_number']) ? $data['group_is_number'] : ''  ); 
        
        $group_id = $this->group->create( $new_group );

        foreach ( $data['group_queries'] as $html_id => $query ) {
            $new_query = array(
                    'title'     => isset($query['query_title'])    ? $query['query_title']    : '' ,
                    'group_id'  => isset($group_id)                ? $group_id                : '' ,
                    'query_qb'  => isset($query['query_query_qb']) ? $query['query_query_qb'] : '' ,
                    'query_bz'  => isset($query['query_query_bz']) ? $query['query_query_bz'] : '' ,
                    'colour'    => isset($query['query_colour'])   ? $query['query_colour']   : ''  );
            
            $query_id = $this->query->create( $new_query );

            if ( isset($query['ref_version']) ) {
                if ( $query['ref_version'] != 'none' ) {
                    $query_version = $query_id . ',' . $query['ref_version'];
                    $new_reference = array(
                        'title'     => isset($query['query_title']) ? $query['query_title'].' ref. <version_title>'    : '' ,
                        'group_id'  => isset($group_id)             ? $group_id                : '' ,
                        'query_qb'  => '' ,
                        'query_bz'  => '' ,
                        'colour'    => isset($query['ref_colour'])  ? $query['ref_colour']     : '' ,
                        'references'=> $query_version  );

                    $ref_id = $this->query->create( $new_reference );
                }
            }
        }
{'fraction_non_alphanumeric': 0.17109031888485773, 'fraction_numerical': 0.0, 'mean_word_length': 1.7041817243159525, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4213432', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1508, 'n_words': 234}