enrichers 1/3

This commit is contained in:
babayaga 2026-01-22 17:24:04 +01:00
parent e5427ebafe
commit e0cef22c5b
2 changed files with 6 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@ -117,6 +117,7 @@ export const searchGoogleMap = async (
key: string, key: string,
opts: IOptionsGoogleMaps, opts: IOptionsGoogleMaps,
) => { ) => {
const roundCoords = (coords: string, decimals: number = 3): string => { const roundCoords = (coords: string, decimals: number = 3): string => {
const [latitude, longitude, zoom] = coords.split(',').map((part, index) => { const [latitude, longitude, zoom] = coords.split(',').map((part, index) => {
if (index < 2) { if (index < 2) {
@ -158,7 +159,6 @@ export const searchGoogleMap = async (
...googleParams ...googleParams
}) })
while (page && page.local_results) { while (page && page.local_results) {
page.local_results.forEach((r) => { page.local_results.forEach((r) => {
r.page = pageIdx r.page = pageIdx
@ -187,12 +187,9 @@ export const searchGoogleMap = async (
set_cached_object(cache_key, MODULE_NAME, results) 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 // Optimization: Defer expensive enrichment (photos, meta) until AFTER filtering
// Only perform cheaper geo-enrichment (reverse geocoding) if needed for 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) 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[]> => { const enrichResults = async (results: GoogleMapResult[], index: any, opts: IOptionsGoogleMaps): Promise<GoogleMapResultInternal[]> => {
let idx = 0 let idx = 0
await pMap( await pMap(
results, results,
async (entry: any) => { async (entry: any) => {
@ -254,6 +252,7 @@ const enrichResults = async (results: GoogleMapResult[], index: any, opts: IOpti
}, },
{ concurrency: opts.concurrency }, { concurrency: opts.concurrency },
) )
if (opts.meta) { if (opts.meta) {
await pMap( await pMap(
results, results,