reset criteria on home, show filter on home, new BOM generation, Schema overhaul

This commit is contained in:
2024-07-23 20:46:38 +02:00
parent 9db23c2177
commit acec14d372
23 changed files with 577 additions and 131 deletions

View File

@@ -44,10 +44,13 @@ const logger = winston.createLogger({
await db.delete(schema.commercials);
await db.delete(schema.businesses);
await db.delete(schema.users);
let filePath = `./src/assets/geo.json`;
const rawData = readFileSync(filePath, 'utf8');
const geos = JSON.parse(rawData);
const sso = new SelectOptionsService();
//Broker
let filePath = `./data/broker.json`;
filePath = `./data/broker.json`;
let data: string = readFileSync(filePath, 'utf8');
const usersData: UserData[] = JSON.parse(data); // Erwartet ein Array von Objekten
const generatedUserData = [];
@@ -70,7 +73,7 @@ fs.ensureDirSync(`./pictures/property`);
//for (const userData of usersData) {
for (let index = 0; index < usersData.length; index++) {
const userData = usersData[index];
const user: User = { firstname: '', lastname: '', email: '' };
const user: User = { id: undefined, firstname: '', lastname: '', email: '' };
user.licensedIn = [];
userData.licensedIn.forEach(l => {
console.log(l['value'], l['name']);
@@ -91,6 +94,10 @@ for (let index = 0; index < usersData.length; index++) {
user.companyOverview = userData.companyOverview;
user.companyWebsite = userData.companyWebsite;
user.companyLocation = userData.companyLocation;
const [city, state] = user.companyLocation.split('-').map(e => e.trim());
const cityGeo = geos.states.find(s => s.state_code === state).cities.find(c => c.name === city);
const latitude = cityGeo.latitude;
const longitude = cityGeo.longitude;
user.offeredServices = userData.offeredServices;
user.gender = userData.gender;
user.customerType = 'professional';
@@ -142,6 +149,13 @@ for (let index = 0; index < commercialJsonData.length; index++) {
commercial.email = user.email;
commercial.draft = false;
commercial.type = sso.typesOfCommercialProperty.find(e => e.oldValue === String(commercial.type)).value;
const cityGeo = geos.states.find(s => s.state_code === commercial.state).cities.find(c => c.name === commercial.city);
try {
const latitude = cityGeo.latitude;
const longitude = cityGeo.longitude;
} catch (e) {
console.log(`----------------> ERROR ${commercial.state} - ${commercial.city}`);
}
// const reducedCommercial = {
// city: commercial.city,
// description: commercial.description,
@@ -175,6 +189,13 @@ for (let index = 0; index < businessJsonData.length; index++) {
const user = getRandomItem(generatedUserData);
business.email = user.email;
business.imageName = emailToDirName(user.email);
const cityGeo = geos.states.find(s => s.state_code === business.state).cities.find(c => c.name === business.city);
try {
const latitude = cityGeo.latitude;
const longitude = cityGeo.longitude;
} catch (e) {
console.log(`----------------> ERROR ${business.state} - ${business.city}`);
}
// const embeddingText = JSON.stringify({
// type: typesOfBusiness.find(b => b.value === String(business.type))?.name,
// title: business.title,