This commit is contained in:
sebseb7
2024-09-23 09:12:52 +02:00
parent 41ebffe71c
commit cc8b5d2765
4 changed files with 128 additions and 94 deletions

View File

@@ -27,30 +27,12 @@ const compiler = webpack({
test: /\.css$/,
use: ["style-loader", "css-loader"]
}
/* {
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}
]
}*/
/*{
test: /\.(woff|woff2)$/i,
use: ['base64-inline-loader'],
type: 'javascript/auto'
}*/
]
},
plugins: [
new HtmlWebpackPlugin({
templateContent: "<!DOCTYPE html>\n<html><head>" + '<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" href="data:;base64,iVBORw0KGgo="></head><body style="background-color: rgb(192,208,208)"></body></html>'
templateContent: "<!DOCTYPE html>\n<html><head>" + '<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" href="data:;base64,iVBORw0KGgo="></head><body style="background-color: #c5cbe3"><div id="react_insert"></div></body></html>'
}),
//new BundleAnalyzerPlugin({analyzerHost:'0.0.0.0'}),
...(isDev ? [new ReactRefreshWebpackPlugin(), new webpack.HotModuleReplacementPlugin(), new ESLintPlugin()] : [])
],
resolve: {
@@ -65,21 +47,21 @@ const compiler = webpack({
optimization: {
moduleIds: "deterministic",
splitChunks: {
chunks: "all",
cacheGroups: {
//chunks: "all",
/*cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
chunks: "all"
}
}
}*/
}
},
output: {
filename: "[name].[contenthash].js",
chunkFilename: "[name].[contenthash].js",
filename: "searchPopper.js",//"[name].[contenthash].js",
chunkFilename: "searchPopper.js",//"[name].[contenthash].js",
clean: true,
asyncChunks: true
asyncChunks: false
}
});
@@ -205,25 +187,46 @@ function runapp(socket){
socket.on("search", (text, offset, callback) => {
try{
text = text.toString().trim().replace(/(\D)-/g, "$1 ").replace(/ {2,}/g, " ");
if(text.length > 2){
let queries = [];
let qstr = '';
let queries = [];
let qstr = '';
for(const per of permute(text.toString().trim().replace(/ {2,}/g, " ").split(' '))){
queries.push('%'+(per.join('%'))+'%');
qstr+= ' OR cName LIKE ? ';
for(const per of permute(text.split(' '))){
for(let i=0;i<per.length;i++) if (!isNaN(parseInt(per[i], 10))) {
per[i] = ' '+per[i];
}
queries.push(offset*10);
queries.push('%'+(per.join('%'))+'%');
qstr+= ' OR cName LIKE ? ';
}
qstr = qstr.substring(3);
connection.query('SELECT tartikel.kArtikel,cArtNr,cName,cSeo FROM tartikel LEFT OUTER JOIN tartikelpict ON (tartikelpict.kArtikel = tartikel.kArtikel) WHERE 1=2 '+qstr+' ORDER BY cName limit 11 OFFSET ?',queries, function (error, results) {
queries.push(offset*10);
if((text.length < 200)&&(text.length > 2)&&(queries.length < 129)){
connection.query(`
SELECT
tartikel.kArtikel,
cArtNr,
cName,
cSeo,
fLieferantenlagerbestand > 0 as bLieferantenlagerbestand,
fLagerbestand > 0 as bLagerbestand,
fStandardpreisNetto,
fMwSt
FROM tartikel
LEFT OUTER JOIN tartikelpict ON (tartikelpict.kArtikel = tartikel.kArtikel AND nNr = 1)
WHERE nIstVater = 0 and ( `+qstr+` ) ORDER BY cName limit 11 OFFSET ?`,
queries, function (error, results)
{
if (callback) callback(error,results);
});
}else{
callback(true);
callback({length:text.length,permutations:queries.length});
}
}
catch(e){