Einbau klassische Filter als Overlay ...
This commit is contained in:
@@ -12,7 +12,6 @@ import winston from 'winston';
|
||||
import { BusinessListing, CommercialPropertyListing, User, UserData } from '../models/db.model.js';
|
||||
import { emailToDirName, KeyValueStyle } from '../models/main.model.js';
|
||||
import * as schema from './schema.js';
|
||||
import { users } from './schema.js';
|
||||
const typesOfBusiness: Array<KeyValueStyle> = [
|
||||
{ name: 'Automotive', value: '1', icon: 'fa-solid fa-car', textColorClass: 'text-green-400' },
|
||||
{ name: 'Industrial Services', value: '2', icon: 'fa-solid fa-industry', textColorClass: 'text-yellow-400' },
|
||||
@@ -65,9 +64,9 @@ deleteFilesOfDir(targetPathProperty);
|
||||
fs.ensureDirSync(`./pictures/logo`);
|
||||
fs.ensureDirSync(`./pictures/profile`);
|
||||
fs.ensureDirSync(`./pictures/property`);
|
||||
type UserProfile = Omit<User, 'created' | 'updated' | 'hasCompanyLogo' | 'hasProfile' | 'id'>;
|
||||
// type UserProfile = Omit<User, 'created' | 'updated' | 'hasCompanyLogo' | 'hasProfile' | 'id'>;
|
||||
|
||||
type NewUser = typeof users.$inferInsert;
|
||||
// type NewUser = typeof users.$inferInsert;
|
||||
//for (const userData of usersData) {
|
||||
for (let index = 0; index < usersData.length; index++) {
|
||||
const userData = usersData[index];
|
||||
@@ -98,20 +97,17 @@ for (let index = 0; index < usersData.length; index++) {
|
||||
user.customerSubType = 'broker';
|
||||
user.created = new Date();
|
||||
user.updated = new Date();
|
||||
const createUserProfile = (user: User): UserProfile => {
|
||||
const { id, created, updated, hasCompanyLogo, hasProfile, ...userProfile } = user;
|
||||
return userProfile;
|
||||
};
|
||||
const userProfile = createUserProfile(user);
|
||||
logger.info(`${index} - ${JSON.stringify(userProfile)}`);
|
||||
const embedding = await createEmbedding(JSON.stringify(userProfile));
|
||||
sleep(200);
|
||||
// const createUserProfile = (user: User): UserProfile => {
|
||||
// const { id, created, updated, hasCompanyLogo, hasProfile, ...userProfile } = user;
|
||||
// return userProfile;
|
||||
// };
|
||||
// const userProfile = createUserProfile(user);
|
||||
// logger.info(`${index} - ${JSON.stringify(userProfile)}`);
|
||||
// const embedding = await createEmbedding(JSON.stringify(userProfile));
|
||||
//sleep(200);
|
||||
const u = await db
|
||||
.insert(schema.users)
|
||||
.values({
|
||||
...user,
|
||||
embedding: embedding,
|
||||
} as NewUser)
|
||||
.values(user)
|
||||
.returning({ insertedId: schema.users.id, gender: schema.users.gender, email: schema.users.email, firstname: schema.users.firstname, lastname: schema.users.lastname });
|
||||
generatedUserData.push(u[0]);
|
||||
i++;
|
||||
@@ -145,25 +141,20 @@ for (let index = 0; index < commercialJsonData.length; index++) {
|
||||
commercial.updated = insertionDate;
|
||||
commercial.email = user.email;
|
||||
commercial.draft = false;
|
||||
const reducedCommercial = {
|
||||
city: commercial.city,
|
||||
description: commercial.description,
|
||||
email: commercial.email,
|
||||
price: commercial.price,
|
||||
state: sso.locations.find(l => l.value === commercial.state)?.name,
|
||||
title: commercial.title,
|
||||
name: `${user.firstname} ${user.lastname}`,
|
||||
};
|
||||
const embedding = await createEmbedding(JSON.stringify(reducedCommercial));
|
||||
sleep(200);
|
||||
const result = await db
|
||||
.insert(schema.commercials)
|
||||
.values({
|
||||
...commercial,
|
||||
embedding: embedding,
|
||||
})
|
||||
.returning();
|
||||
logger.info(`commercial_${index} inserted`);
|
||||
commercial.type = sso.typesOfCommercialProperty.find(e => e.oldValue === String(commercial.type)).value;
|
||||
// const reducedCommercial = {
|
||||
// city: commercial.city,
|
||||
// description: commercial.description,
|
||||
// email: commercial.email,
|
||||
// price: commercial.price,
|
||||
// state: sso.locations.find(l => l.value === commercial.state)?.name,
|
||||
// title: commercial.title,
|
||||
// name: `${user.firstname} ${user.lastname}`,
|
||||
// };
|
||||
// const embedding = await createEmbedding(JSON.stringify(reducedCommercial));
|
||||
// sleep(200);
|
||||
const result = await db.insert(schema.commercials).values(commercial).returning();
|
||||
// logger.info(`commercial_${index} inserted`);
|
||||
try {
|
||||
fs.copySync(`./pictures_base/property/${id}`, `./pictures/property/${result[0].imagePath}/${result[0].serialId}`);
|
||||
} catch (err) {
|
||||
@@ -178,37 +169,34 @@ const businessJsonData = JSON.parse(data) as BusinessListing[]; // Erwartet ein
|
||||
for (let index = 0; index < businessJsonData.length; index++) {
|
||||
const business = businessJsonData[index];
|
||||
delete business.id;
|
||||
business.type = sso.typesOfBusiness.find(e => e.oldValue === String(business.type)).value;
|
||||
business.created = new Date(business.created);
|
||||
business.updated = new Date(business.created);
|
||||
const user = getRandomItem(generatedUserData);
|
||||
business.email = user.email;
|
||||
business.imageName = emailToDirName(user.email);
|
||||
const embeddingText = JSON.stringify({
|
||||
type: typesOfBusiness.find(b => b.value === String(business.type))?.name,
|
||||
title: business.title,
|
||||
description: business.description,
|
||||
email: business.email,
|
||||
city: business.city,
|
||||
state: sso.locations.find(l => l.value === business.state)?.name,
|
||||
price: business.price,
|
||||
realEstateIncluded: business.realEstateIncluded,
|
||||
leasedLocation: business.leasedLocation,
|
||||
franchiseResale: business.franchiseResale,
|
||||
salesRevenue: business.salesRevenue,
|
||||
cashFlow: business.cashFlow,
|
||||
supportAndTraining: business.supportAndTraining,
|
||||
employees: business.employees,
|
||||
established: business.established,
|
||||
reasonForSale: business.reasonForSale,
|
||||
name: `${user.firstname} ${user.lastname}`,
|
||||
});
|
||||
const embedding = await createEmbedding(embeddingText);
|
||||
// const embeddingText = JSON.stringify({
|
||||
// type: typesOfBusiness.find(b => b.value === String(business.type))?.name,
|
||||
// title: business.title,
|
||||
// description: business.description,
|
||||
// email: business.email,
|
||||
// city: business.city,
|
||||
// state: sso.locations.find(l => l.value === business.state)?.name,
|
||||
// price: business.price,
|
||||
// realEstateIncluded: business.realEstateIncluded,
|
||||
// leasedLocation: business.leasedLocation,
|
||||
// franchiseResale: business.franchiseResale,
|
||||
// salesRevenue: business.salesRevenue,
|
||||
// cashFlow: business.cashFlow,
|
||||
// supportAndTraining: business.supportAndTraining,
|
||||
// employees: business.employees,
|
||||
// established: business.established,
|
||||
// reasonForSale: business.reasonForSale,
|
||||
// name: `${user.firstname} ${user.lastname}`,
|
||||
// });
|
||||
// const embedding = await createEmbedding(embeddingText);
|
||||
sleep(200);
|
||||
await db.insert(schema.businesses).values({
|
||||
...business,
|
||||
embedding: embedding,
|
||||
});
|
||||
logger.info(`business_${index} inserted`);
|
||||
await db.insert(schema.businesses).values(business);
|
||||
}
|
||||
|
||||
//End
|
||||
|
||||
Reference in New Issue
Block a user