<commit_before><?php

    class Ajax extends AjaxBase {
        
        var $arg_list = array('time' => '\d+', 'bl' => '\w\d\d(-\d)?', 'sid' => '\d+', 'cid' => '\d+', 'scid' => '\d+', 'pp' => '\d+', 'page' => '\d+', 'array' => '\d', 'ty' => '\w+', 'fid' => '\d+', 'name' => '[A-Za-z0-9_\- ]+', 'desc' => '[A-Za-z0-9_\- ]+', 's' => '\w+');
        var $dispatch = array('list' => '_get_faults',
                              
                              'visits' => '_get_visits',
                              'bls' => '_get_beamlines',
                              'sys' => '_get_systems',
                              'com' => '_get_components',
                              'scom' => '_get_subcomponents',
                              
                              'add' => '_add_fault',
                              
                              'bladd' => '_add_beamline',
                              'sysadd' => '_add_system',
                              'comadd' => '_add_component',
                              'scomadd' => '_add_subcomponent',

                              'ec' => '_edit_component',
                              'dc' => '_delete_component',
                              
                              'update' => '_update_fault',
                              
                              );
        var $def = 'list';
        var $profile = True;
        #var $debug = True;
        
        # ------------------------------------------------------------------------
        # Return faults based on search terms / filters
        function _get_faults() {
            $args = array();
            $where = array();
            
            if ($this->has_arg('s')) {
                $st = sizeof($args) + 1;
                array_push($where, "(f.title LIKE '%'||:".$st."||'%' OR f.description LIKE '%'||:".($st+1)."||'%')");
                array_push($args, $this->arg('s'));
                array_push($args, $this->arg('s'));
            }
            
            if ($this->has_arg('sid')) {
                array_push($where, 's.systemid=:'.(sizeof($args) + 1));
                array_push($args, $this->arg('sid'));
            }

            if ($this->has_arg('cid')) {
                array_push($where, 'c.componentid=:'.(sizeof($args) + 1));
                array_push($args, $this->arg('cid'));
            }
            <commit_msg>make fault searches case insensitive and search system / component names too<commit_after><?php

    class Ajax extends AjaxBase {
        
        var $arg_list = array('time' => '\d+', 'bl' => '\w\d\d(-\d)?', 'sid' => '\d+', 'cid' => '\d+', 'scid' => '\d+', 'pp' => '\d+', 'page' => '\d+', 'array' => '\d', 'ty' => '\w+', 'fid' => '\d+', 'name' => '[A-Za-z0-9_\- ]+', 'desc' => '[A-Za-z0-9_\- ]+', 's' => '\w+');
        var $dispatch = array('list' => '_get_faults',
                              
                              'visits' => '_get_visits',
                              'bls' => '_get_beamlines',
                              'sys' => '_get_systems',
                              'com' => '_get_components',
                              'scom' => '_get_subcomponents',
                              
                              'add' => '_add_fault',
                              
                              'bladd' => '_add_beamline',
                              'sysadd' => '_add_system',
                              'comadd' => '_add_component',
                              'scomadd' => '_add_subcomponent',

                              'ec' => '_edit_component',
                              'dc' => '_delete_component',
                              
                              'update' => '_update_fault',
                              
                              );
        var $def = 'list';
        var $profile = True;
        #var $debug = True;
        
        # ------------------------------------------------------------------------
        # Return faults based on search terms / filters
        function _get_faults() {
            $args = array();
            $where = array();
            
            if ($this->has_arg('s')) {
                $st = sizeof($args) + 1;
                array_push($where, "(lower(f.title) LIKE lower('%'||:".$st."||'%') OR lower(f.description) LIKE lower('%'||:".($st+1)."||'%') OR lower(s.name) LIKE lower('%'||:".($st+2)."||'%') OR lower(c.name) LIKE lower('%'||:".($st+3)."||'%') OR lower(sc.name) LIKE lower('%'||:".($st+4)."||'%'))");
                for ($i = 0; $i < 5; $i++) array_push($args, $this->arg('s'));
            }
            
            if ($this->has_arg('sid')) {
                array_push($where, 's.systemid=:'.(sizeof($args) + 1));
                array_push($args, $this->arg('sid'));
            }

            if ($this->has_arg('cid')) {
                array_push($where, 'c.componentid=:'.(sizeof($args) + 1));
                array_push($args, $this->arg('cid'));
            }
            
{'fraction_non_alphanumeric': 0.2213359920239282, 'fraction_numerical': 0.004187437686939182, 'mean_word_length': 1.0532132623823167, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 70, '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': '3500378', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1396, 'n_words': 258}