fix: 맛집 중복 체크 및 카테고리 필터 로직 개선
1. placeId 기반 중복 체크 제거 - 이전 대화에서 명확히 한 대로 placeId는 매칭에 사용하지 않음 2. 주소 기반 매칭 개선 - 주소가 있을 때만 주소 기반 중복 체크 수행 3. 위치 기반 매칭 추가 - 50m 이내 동일한 이름의 맛집 중복 체크 추가 4. 검색 결과 선택 로직 개선 - 주소가 없을 때 가장 가까운 거리의 업체 선택 5. 카테고리 필터 버그 수정 - 카테고리 표시명과 실제 값 불일치 문제 해결 - 부분 일치 및 정규화된 비교 지원 6. 빈 상태 메시지 개선 - 필터링 중일 때 적절한 안내 메시지 표시 - 필터 초기화 버튼 추가 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import '../../api/naver_api_client.dart';
|
||||
import '../../api/naver/naver_local_search_api.dart';
|
||||
import '../../../domain/entities/restaurant.dart';
|
||||
import '../../../core/errors/network_exceptions.dart';
|
||||
import '../../../core/utils/distance_calculator.dart';
|
||||
import 'naver_map_parser.dart';
|
||||
|
||||
/// 네이버 검색 서비스
|
||||
@@ -111,8 +112,14 @@ class NaverSearchService {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 가장 유사한 결과 찾기
|
||||
final bestMatch = _findBestMatch(name, searchResults);
|
||||
// 가장 유사한 결과 찾기 (주소가 없으면 거리 기반 선택 포함)
|
||||
final bestMatch = _findBestMatch(
|
||||
name,
|
||||
searchResults,
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
address: address,
|
||||
);
|
||||
|
||||
if (bestMatch != null) {
|
||||
final restaurant = bestMatch.toRestaurant(id: _uuid.v4());
|
||||
@@ -172,8 +179,11 @@ class NaverSearchService {
|
||||
/// 가장 유사한 검색 결과 찾기
|
||||
NaverLocalSearchResult? _findBestMatch(
|
||||
String targetName,
|
||||
List<NaverLocalSearchResult> results,
|
||||
) {
|
||||
List<NaverLocalSearchResult> results, {
|
||||
double? latitude,
|
||||
double? longitude,
|
||||
String? address,
|
||||
}) {
|
||||
if (results.isEmpty) return null;
|
||||
|
||||
// 정확히 일치하는 결과 우선
|
||||
@@ -186,6 +196,28 @@ class NaverSearchService {
|
||||
return exactMatch;
|
||||
}
|
||||
|
||||
// 주소가 없고 위치 정보가 있는 경우 - 가장 가까운 업체 선택
|
||||
if ((address == null || address.isEmpty) && latitude != null && longitude != null) {
|
||||
NaverLocalSearchResult? closestResult;
|
||||
double minDistance = double.infinity;
|
||||
|
||||
for (final result in results) {
|
||||
final distance = DistanceCalculator.calculateDistance(
|
||||
lat1: latitude,
|
||||
lon1: longitude,
|
||||
lat2: result.latitude,
|
||||
lon2: result.longitude,
|
||||
);
|
||||
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
closestResult = result;
|
||||
}
|
||||
}
|
||||
|
||||
return closestResult ?? results.first;
|
||||
}
|
||||
|
||||
// 유사도 계산 (간단한 버전)
|
||||
NaverLocalSearchResult? bestMatch;
|
||||
double bestScore = 0.0;
|
||||
@@ -239,9 +271,18 @@ class NaverSearchService {
|
||||
@visibleForTesting
|
||||
NaverLocalSearchResult? findBestMatchForTesting(
|
||||
String targetName,
|
||||
List<NaverLocalSearchResult> results,
|
||||
) {
|
||||
return _findBestMatch(targetName, results);
|
||||
List<NaverLocalSearchResult> results, {
|
||||
double? latitude,
|
||||
double? longitude,
|
||||
String? address,
|
||||
}) {
|
||||
return _findBestMatch(
|
||||
targetName,
|
||||
results,
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
address: address,
|
||||
);
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
|
||||
Reference in New Issue
Block a user