function GenerateReqest(req = null, threshold = 0.5){
if(!req){
let fldprob = Math.ceil(PrivacyProfile.table.length * Math.random()) / PrivacyProfile.length;
req = PrivacyProfile.table.filter(d=>(Math.random()<fldprob)).map(d=>d.Field);
}
req = PrivacyProfile.table.filter(d=>req.includes(d.Field)).map(d=>d.Field);
let rtn = {
req: req
};
rtn.score = rtn.req.reduce((a,d)=>a*PrivacyProfile.hashed[d]['PrivacyFactor'],1);
rtn.score = rtn.score.toString().includes('e') ? 0 : rtn.score;
rtn.threshold = threshold ?? 0.5;
rtn.threshold = Math.max(rtn.threshold,0);
rtn.threshold = Math.min(rtn.threshold,1);
if(rtn.score < rtn.threshold){
rtn.data = null;
return rtn;
}
rtn.data = basedata.map(d=>{
d = rtn.req.reduce((a,f)=>{
a[f] = d[f];
return a;
},{});
d = Object.assign({
id: Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(32)
},d);
return d;
});
return rtn;
}