enrichers 1/3
This commit is contained in:
parent
e5427ebafe
commit
e0cef22c5b
File diff suppressed because one or more lines are too long
@ -117,6 +117,7 @@ export const searchGoogleMap = async (
|
||||
key: string,
|
||||
opts: IOptionsGoogleMaps,
|
||||
) => {
|
||||
|
||||
const roundCoords = (coords: string, decimals: number = 3): string => {
|
||||
const [latitude, longitude, zoom] = coords.split(',').map((part, index) => {
|
||||
if (index < 2) {
|
||||
@ -158,7 +159,6 @@ export const searchGoogleMap = async (
|
||||
...googleParams
|
||||
})
|
||||
|
||||
|
||||
while (page && page.local_results) {
|
||||
page.local_results.forEach((r) => {
|
||||
r.page = pageIdx
|
||||
@ -187,12 +187,9 @@ export const searchGoogleMap = async (
|
||||
set_cached_object(cache_key, MODULE_NAME, results)
|
||||
}
|
||||
|
||||
let idx = 0
|
||||
//const cachedLoc = async (title: string) => getStored(title, opts.store, MODULE_NAME)
|
||||
|
||||
// Optimization: Defer expensive enrichment (photos, meta) until AFTER filtering
|
||||
// Only perform cheaper geo-enrichment (reverse geocoding) if needed for filtering
|
||||
const preFilterOpts = { ...opts, resolve: [], meta: true, findEMail: false }
|
||||
const preFilterOpts = { ...opts, resolve: [], meta: false, findEMail: false }
|
||||
|
||||
await enrichResults(results as GoogleMapResult[], index, preFilterOpts)
|
||||
|
||||
@ -236,6 +233,7 @@ export const searchGoogleMap = async (
|
||||
|
||||
const enrichResults = async (results: GoogleMapResult[], index: any, opts: IOptionsGoogleMaps): Promise<GoogleMapResultInternal[]> => {
|
||||
let idx = 0
|
||||
|
||||
await pMap(
|
||||
results,
|
||||
async (entry: any) => {
|
||||
@ -254,6 +252,7 @@ const enrichResults = async (results: GoogleMapResult[], index: any, opts: IOpti
|
||||
},
|
||||
{ concurrency: opts.concurrency },
|
||||
)
|
||||
|
||||
if (opts.meta) {
|
||||
await pMap(
|
||||
results,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user