feat: Initialize Angular SSR application with core pages, components, and server setup.
This commit is contained in:
@@ -31,20 +31,35 @@ export class BusinessListingService {
|
||||
const cityGeo = this.geoService.getCityWithCoords(criteria.state, criteria.city.name);
|
||||
whereConditions.push(sql`${getDistanceQuery(businesses_json, cityGeo.latitude, cityGeo.longitude)} <= ${criteria.radius}`);
|
||||
}
|
||||
if (criteria.types && criteria.types.length > 0) {
|
||||
whereConditions.push(inArray(sql`${businesses_json.data}->>'type'`, criteria.types));
|
||||
if (criteria.types && Array.isArray(criteria.types) && criteria.types.length > 0) {
|
||||
const validTypes = criteria.types.filter(t => t !== null && t !== undefined && t !== '');
|
||||
if (validTypes.length > 0) {
|
||||
whereConditions.push(inArray(sql`${businesses_json.data}->>'type'`, validTypes));
|
||||
}
|
||||
}
|
||||
|
||||
if (criteria.state) {
|
||||
whereConditions.push(sql`(${businesses_json.data}->'location'->>'state') = ${criteria.state}`);
|
||||
}
|
||||
|
||||
if (criteria.minPrice) {
|
||||
whereConditions.push(gte(sql`(${businesses_json.data}->>'price')::double precision`, criteria.minPrice));
|
||||
if (criteria.minPrice !== undefined && criteria.minPrice !== null) {
|
||||
whereConditions.push(
|
||||
and(
|
||||
sql`(${businesses_json.data}->>'price') IS NOT NULL`,
|
||||
sql`(${businesses_json.data}->>'price') != ''`,
|
||||
gte(sql`REPLACE(${businesses_json.data}->>'price', ',', '')::double precision`, criteria.minPrice)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (criteria.maxPrice) {
|
||||
whereConditions.push(lte(sql`(${businesses_json.data}->>'price')::double precision`, criteria.maxPrice));
|
||||
if (criteria.maxPrice !== undefined && criteria.maxPrice !== null) {
|
||||
whereConditions.push(
|
||||
and(
|
||||
sql`(${businesses_json.data}->>'price') IS NOT NULL`,
|
||||
sql`(${businesses_json.data}->>'price') != ''`,
|
||||
lte(sql`REPLACE(${businesses_json.data}->>'price', ',', '')::double precision`, criteria.maxPrice)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (criteria.minRevenue) {
|
||||
@@ -87,8 +102,14 @@ export class BusinessListingService {
|
||||
whereConditions.push(eq(sql`(${businesses_json.data}->>'franchiseResale')::boolean`, criteria.franchiseResale));
|
||||
}
|
||||
|
||||
if (criteria.title) {
|
||||
whereConditions.push(sql`(${businesses_json.data}->>'title') ILIKE ${`%${criteria.title}%`} OR (${businesses_json.data}->>'description') ILIKE ${`%${criteria.title}%`}`);
|
||||
if (criteria.title && criteria.title.trim() !== '') {
|
||||
const searchTerm = `%${criteria.title.trim()}%`;
|
||||
whereConditions.push(
|
||||
or(
|
||||
sql`(${businesses_json.data}->>'title') ILIKE ${searchTerm}`,
|
||||
sql`(${businesses_json.data}->>'description') ILIKE ${searchTerm}`
|
||||
)
|
||||
);
|
||||
}
|
||||
if (criteria.brokerName) {
|
||||
const { firstname, lastname } = splitName(criteria.brokerName);
|
||||
@@ -122,9 +143,16 @@ export class BusinessListingService {
|
||||
|
||||
const whereConditions = this.getWhereConditions(criteria, user);
|
||||
|
||||
// Uncomment for debugging filter issues:
|
||||
// this.logger.info('Filter Criteria:', { criteria });
|
||||
// this.logger.info('Where Conditions Count:', { count: whereConditions.length });
|
||||
|
||||
if (whereConditions.length > 0) {
|
||||
const whereClause = and(...whereConditions);
|
||||
query.where(whereClause);
|
||||
|
||||
// Uncomment for debugging SQL queries:
|
||||
// this.logger.info('Generated SQL:', { sql: query.toSQL() });
|
||||
}
|
||||
|
||||
// Sortierung
|
||||
|
||||
Reference in New Issue
Block a user