<commit_before><?php

class Nbd extends Model
{
    
    function __construct()
    {
		parent::__construct('id', strtolower(get_class($this))); //primary key, tablename
        $this->rs['id'] = '';
        $this->rs['port'] = ''; $this->rt['port'] = 'varchar(20)';
        $this->rs['vlan'] = 0;
        $this->rs['speed'] = 0;
        $this->rs['status'] = ''; $this->rt['status'] = 'char(4)';
        $this->rs['ip_address'] = ''; $this->rt['ip_address'] = 'char(15)';
        $this->rs['hostname'] = ''; $this->rt['hostname'] = 'varchar(100)';
        $this->rs['mac_address'] = ''; $this->rt['mac_address'] = 'char(17)';
        $this->rs['room'] = ''; $this->rt['room'] = 'varchar(20)';
        $this->rs['out_mb'] = 0.0;
        $this->rs['in_mb'] = 0.0;
        $this->rs['poe'] = $this->rt['poe'] = 'varchar(100)';
        $this->rs['timestamp'] = time();


        // Add indexes
        $this->idx[] = array('room');
        $this->idx[] = array('mac_address');

        // Table version. Increment when creating a db migration
        $this->schema_version = 0;

		// Create table if it does not exist
        $this->create_table();
        
        return $this;
    }

    /**
     * Process uploaded file
     *
     * @return void
     * @author 
     **/
    function process($handle)
    {
        // Get database handle
        $dbh = $this->getdbh();

        $cnt = 0;

        // Wrap in transaction
        $dbh->beginTransaction();

        // Remove previous data
        $dbh->exec('DELETE FROM '.$this->tablename);

        // Read csv data
        while (($data = fgetcsv($handle, 0, ";", '"')) !== FALSE)
        {
            // Prepend array with id, account for extra item because of next()
            array_unshift($data, '', ''); 

            // Loop through fields
            foreach($this->rs as &$value)
            {
              $value = next($data);
            }
            $this->rs['timestamp'] = time();

            $this->save();
            $cnt++;
        }

        $dbh->commit();

        alert("Imported $cnt network ports", 'success');

    
    }

}<commit_msg>Uppercase nbd mac address<commit_after><?php

class Nbd extends Model
{
    
    function __construct()
    {
		parent::__construct('id', strtolower(get_class($this))); //primary key, tablename
        $this->rs['id'] = '';
        $this->rs['port'] = ''; $this->rt['port'] = 'varchar(20)';
        $this->rs['vlan'] = 0;
        $this->rs['speed'] = 0;
        $this->rs['status'] = ''; $this->rt['status'] = 'char(4)';
        $this->rs['ip_address'] = ''; $this->rt['ip_address'] = 'char(15)';
        $this->rs['hostname'] = ''; $this->rt['hostname'] = 'varchar(100)';
        $this->rs['mac_address'] = ''; $this->rt['mac_address'] = 'char(17)';
        $this->rs['room'] = ''; $this->rt['room'] = 'varchar(20)';
        $this->rs['out_mb'] = 0.0;
        $this->rs['in_mb'] = 0.0;
        $this->rs['poe'] = $this->rt['poe'] = 'varchar(100)';
        $this->rs['timestamp'] = time();


        // Add indexes
        $this->idx[] = array('room');
        $this->idx[] = array('mac_address');

        // Table version. Increment when creating a db migration
        $this->schema_version = 0;

		// Create table if it does not exist
        $this->create_table();
        
        return $this;
    }

    /**
     * Process uploaded file
     *
     * @return void
     * @author 
     **/
    function process($handle)
    {
        // Get database handle
        $dbh = $this->getdbh();

        $cnt = 0;

        // Wrap in transaction
        $dbh->beginTransaction();

        // Remove previous data
        $dbh->exec('DELETE FROM '.$this->tablename);

        $time = time();

        // Read csv data
        while (($data = fgetcsv($handle, 0, ";", '"')) !== FALSE)
        {
            // Prepend array with id, account for extra item because of next()
            array_unshift($data, '', ''); 

            // Loop through fields
            foreach($this->rs as &$value)
            {
              $value = next($data);
            }
            $this->rs['timestamp'] = $time;

            $this->rs['mac_address'] = strtoupper($this->rs['mac_address']);

            $this->save();
            $cnt++;
        }

        $dbh->commit();

        alert("Imported $cnt network ports", 'success');

    
    }

}
{'fraction_non_alphanumeric': 0.2066115702479339, 'fraction_numerical': 0.011019283746556474, 'mean_word_length': 1.896941489361702, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, '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': '2083794', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1372, 'n_words': 273}