From 22162e2e8a4d8d49ebe801d3dd2b72569c0a7550 Mon Sep 17 00:00:00 2001 From: Will Budicm Date: Mon, 28 Dec 2020 16:22:35 +1100 Subject: [PATCH] AUTO_WRD_LMT QUERY had orring instead of filter with and. --- htdocs/cgi-bin/main.cgi | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 5264608..cbd6926 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -297,14 +297,19 @@ qq(
} if ($stmD) { + #was previous an OR?, replace with an AND we filter further by keywords. + $stmS =~ s/\sOR$/ and/gi; $stmS .= $stmD . " AND"; } if (@keywords) { foreach (@keywords) { - if(Settings::isProgressDB()){$stmS .= " LOWER(LOG) ~ '" . lc $_ . "'"}else{$stmS .= " LOWER(LOG) REGEXP '\\b" . lc $_ . "\\b'"} + #was previous an OR?, replace with an AND we filter further by keywords. + $stmS =~ s/\sOR$/ and/gi; + if(Settings::isProgressDB()){$stmS .= " LOWER(LOG) ~ '" . lc $_ . "'"} + else{$stmS .= " LOWER(LOG) REGEXP '\\b" . lc $_ . "\\b'"} if ( \$_ != \$keywords[-1] ) { - $stmS = $stmS . " OR "; + $stmS = $stmS . " and "; } } $sqlVWL = $stmS . $stmE; @@ -1313,24 +1318,31 @@ sub authenticate { } } + sub fetchAutocomplete { - my $st = traceDBExe('SELECT LOG from LOG' . $stmE ); + my $st = traceDBExe('select LOG from LOG ' . $stmE. '-- > '. &Settings::autoWordLimit.' < -- fetchAutocomplete'); my $awl = Settings::autoWordLength(); - my %hsh = (); + my %hsh = (); + my $lst = "\"\""; while ( my @row = $st->fetchrow_array() ) { my ($wl,$log) = ("",$row[0]); #Decode escaped \\n $log =~ s/\\n/\n/gs; $log =~ s/''/'/g; my @words = split( /\s/, $log ); - foreach my $word (@words) { + foreach my $word (sort @words) { #remove all non alphanumerics $word =~ s/[^a-zA-Z]//gs; $wl = length($word); - if ( $wl > 2 && $wl < $awl) { - $word = lc $word; - if(!$hsh{$word}){ $hsh{$word}=$word;$autowords .= qq(,"$word");} else{ next; } + if ( $wl > 2 && $wl < $awl) {# Gas Bootle + $word = lc $word; + if(!$hsh{$word}){ + $hsh{$word}=1; + $lst .= qq(,"$word"); + } else{ + next; + } if ( $aw_cnt++ > &Settings::autoWordLimit ) { last; } @@ -1340,6 +1352,7 @@ sub fetchAutocomplete { last; } } + $autowords = $lst if(length($lst)>1); undef %hsh; } -- 2.34.1