reset criteria on home, show filter on home, new BOM generation, Schema overhaul
This commit is contained in:
@@ -9,6 +9,16 @@ import { FileService } from '../file/file.service.js';
|
||||
import { BusinessListing, CommercialPropertyListing } from '../models/db.model';
|
||||
import { BusinessListingCriteria, emailToDirName, JwtUser } from '../models/main.model.js';
|
||||
|
||||
const EARTH_RADIUS_KM = 6371; // Erdradius in Kilometern
|
||||
|
||||
const getDistanceQuery = (lat: number, lon: number) => sql`
|
||||
${EARTH_RADIUS_KM} * 2 * ASIN(SQRT(
|
||||
POWER(SIN((${lat} - ${businesses.latitude}) * PI() / 180 / 2), 2) +
|
||||
COS(${lat} * PI() / 180) * COS(${businesses.latitude} * PI() / 180) *
|
||||
POWER(SIN((${lon} - ${businesses.longitude}) * PI() / 180 / 2), 2)
|
||||
))
|
||||
`;
|
||||
|
||||
@Injectable()
|
||||
export class BusinessListingService {
|
||||
constructor(
|
||||
@@ -142,7 +152,7 @@ export class BusinessListingService {
|
||||
const [{ value: totalCount }] = await countQuery;
|
||||
return totalCount;
|
||||
}
|
||||
async findBusinessesById(id: string, user: JwtUser): Promise<CommercialPropertyListing> {
|
||||
async findBusinessesById(id: string, user: JwtUser): Promise<BusinessListing> {
|
||||
let result = await this.conn
|
||||
.select()
|
||||
.from(businesses)
|
||||
@@ -159,7 +169,7 @@ export class BusinessListingService {
|
||||
return (await this.conn
|
||||
.select()
|
||||
.from(businesses)
|
||||
.where(and(...conditions))) as CommercialPropertyListing[];
|
||||
.where(and(...conditions))) as BusinessListing[];
|
||||
}
|
||||
// #### CREATE ########################################
|
||||
async createListing(data: BusinessListing): Promise<BusinessListing> {
|
||||
|
||||
Reference in New Issue
Block a user