fix: correct OtherChannels URLs — Google Maps, Naver Blog, Naver Place
Google Maps: was using gm.website (clinic's own site) → now always generates maps.google.com/search URL Naver Blog: was linking to first search result post (random personal blog) → now links to Naver blog search results page Naver Place: np.link was the clinic's own website, not Naver Place → now generates map.naver.com search URL. Also fixed collect-channel-data to search with "성형외과" suffix and match by category (성형/피부) to avoid same-name dental clinics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>claude/bold-hawking
parent
a02c83155e
commit
29c1faf49e
|
|
@ -994,7 +994,8 @@ export function mergeEnrichment(
|
||||||
name: '구글 지도',
|
name: '구글 지도',
|
||||||
status: 'active' as const,
|
status: 'active' as const,
|
||||||
details: `평점: ${gm.rating ?? '-'} / 리뷰: ${gm.reviewCount ?? '-'}`,
|
details: `평점: ${gm.rating ?? '-'} / 리뷰: ${gm.reviewCount ?? '-'}`,
|
||||||
url: gm.website || (gm.name ? `https://www.google.com/maps/search/${encodeURIComponent(String(gm.name))}` : ''),
|
// Always use Google Maps search URL — gm.website is the clinic's own site, not Maps
|
||||||
|
url: gm.name ? `https://www.google.com/maps/search/${encodeURIComponent(String(gm.name))}` : '',
|
||||||
};
|
};
|
||||||
if (gmChannelIdx >= 0) {
|
if (gmChannelIdx >= 0) {
|
||||||
merged.otherChannels[gmChannelIdx] = gmChannel;
|
merged.otherChannels[gmChannelIdx] = gmChannel;
|
||||||
|
|
@ -1089,7 +1090,8 @@ export function mergeEnrichment(
|
||||||
name: '네이버 블로그',
|
name: '네이버 블로그',
|
||||||
status: 'active' as const,
|
status: 'active' as const,
|
||||||
details: `검색 결과: ${nb.totalResults?.toLocaleString() ?? '-'}건 / 최근 포스트 ${nb.posts?.length ?? 0}개`,
|
details: `검색 결과: ${nb.totalResults?.toLocaleString() ?? '-'}건 / 최근 포스트 ${nb.posts?.length ?? 0}개`,
|
||||||
url: nb.posts?.[0]?.link || (nb.searchQuery ? `https://search.naver.com/search.naver?query=${encodeURIComponent(String(nb.searchQuery))}` : ''),
|
// Always link to Naver blog search — individual post links may be unrelated personal blogs
|
||||||
|
url: nb.searchQuery ? `https://search.naver.com/search.naver?where=blog&query=${encodeURIComponent(String(nb.searchQuery))}` : '',
|
||||||
};
|
};
|
||||||
if (nbChannelIdx >= 0) {
|
if (nbChannelIdx >= 0) {
|
||||||
merged.otherChannels[nbChannelIdx] = nbChannel;
|
merged.otherChannels[nbChannelIdx] = nbChannel;
|
||||||
|
|
@ -1106,7 +1108,9 @@ export function mergeEnrichment(
|
||||||
name: '네이버 플레이스',
|
name: '네이버 플레이스',
|
||||||
status: 'active' as const,
|
status: 'active' as const,
|
||||||
details: np.category || '',
|
details: np.category || '',
|
||||||
url: np.link || '',
|
// np.link is the clinic's own website, NOT Naver Place page
|
||||||
|
// Use Naver Place search URL instead
|
||||||
|
url: np.name ? `https://map.naver.com/v5/search/${encodeURIComponent(String(np.name))}` : '',
|
||||||
};
|
};
|
||||||
if (npChannelIdx >= 0) {
|
if (npChannelIdx >= 0) {
|
||||||
merged.otherChannels[npChannelIdx] = npChannel;
|
merged.otherChannels[npChannelIdx] = npChannel;
|
||||||
|
|
|
||||||
|
|
@ -247,17 +247,34 @@ Deno.serve(async (req) => {
|
||||||
})());
|
})());
|
||||||
|
|
||||||
tasks.push((async () => {
|
tasks.push((async () => {
|
||||||
const query = encodeURIComponent(clinicName);
|
// Try multiple queries to find the correct place (avoid same-name different clinics)
|
||||||
|
const queries = [
|
||||||
|
`${clinicName} 성형외과`,
|
||||||
|
`${clinicName} 성형`,
|
||||||
|
clinicName,
|
||||||
|
];
|
||||||
|
for (const q of queries) {
|
||||||
|
const query = encodeURIComponent(q);
|
||||||
const res = await fetch(`https://openapi.naver.com/v1/search/local.json?query=${query}&display=5&sort=comment`, { headers: naverHeaders });
|
const res = await fetch(`https://openapi.naver.com/v1/search/local.json?query=${query}&display=5&sort=comment`, { headers: naverHeaders });
|
||||||
if (!res.ok) return;
|
if (!res.ok) continue;
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
const place = (data.items || [])[0];
|
// Find the best match: prefer category containing 성형 or 피부
|
||||||
if (place) {
|
const items = (data.items || []) as Record<string, string>[];
|
||||||
|
const match = items.find(i =>
|
||||||
|
(i.category || '').includes('성형') || (i.category || '').includes('피부')
|
||||||
|
) || items.find(i => {
|
||||||
|
const name = (i.title || '').replace(/<[^>]*>/g, '').toLowerCase();
|
||||||
|
return name.includes(clinicName.replace(/성형외과|병원|의원/g, '').trim().toLowerCase());
|
||||||
|
}) || null;
|
||||||
|
|
||||||
|
if (match) {
|
||||||
channelData.naverPlace = {
|
channelData.naverPlace = {
|
||||||
name: (place.title || "").replace(/<[^>]*>/g, ""),
|
name: (match.title || "").replace(/<[^>]*>/g, ""),
|
||||||
category: place.category, address: place.roadAddress || place.address,
|
category: match.category, address: match.roadAddress || match.address,
|
||||||
telephone: place.telephone, link: place.link, mapx: place.mapx, mapy: place.mapy,
|
telephone: match.telephone, link: match.link, mapx: match.mapx, mapy: match.mapy,
|
||||||
};
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})());
|
})());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue