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
Haewon Kam 2026-04-04 21:25:26 +09:00
parent a02c83155e
commit 29c1faf49e
2 changed files with 35 additions and 14 deletions

View File

@ -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;

View File

@ -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 res = await fetch(`https://openapi.naver.com/v1/search/local.json?query=${query}&display=5&sort=comment`, { headers: naverHeaders }); const queries = [
if (!res.ok) return; `${clinicName} 성형외과`,
const data = await res.json(); `${clinicName} 성형`,
const place = (data.items || [])[0]; clinicName,
if (place) { ];
channelData.naverPlace = { for (const q of queries) {
name: (place.title || "").replace(/<[^>]*>/g, ""), const query = encodeURIComponent(q);
category: place.category, address: place.roadAddress || place.address, const res = await fetch(`https://openapi.naver.com/v1/search/local.json?query=${query}&display=5&sort=comment`, { headers: naverHeaders });
telephone: place.telephone, link: place.link, mapx: place.mapx, mapy: place.mapy, if (!res.ok) continue;
}; const data = await res.json();
// Find the best match: prefer category containing 성형 or 피부
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 = {
name: (match.title || "").replace(/<[^>]*>/g, ""),
category: match.category, address: match.roadAddress || match.address,
telephone: match.telephone, link: match.link, mapx: match.mapx, mapy: match.mapy,
};
break;
}
} }
})()); })());
} }