From db0be8671ed3a4697185bffe559ffbca83c4f322 Mon Sep 17 00:00:00 2001 From: albertfj114 Date: Thu, 19 Mar 2026 19:03:51 -0400 Subject: [PATCH] feat: add buscarmisasNetworkId (and discovermassId) to church-matcher interfaces and ID-match passes Co-Authored-By: Claude Sonnet 4.6 --- src/lib/church-matcher.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lib/church-matcher.ts b/src/lib/church-matcher.ts index 3de70be..692fb22 100644 --- a/src/lib/church-matcher.ts +++ b/src/lib/church-matcher.ts @@ -28,6 +28,7 @@ export interface ExistingChurch { kerknetId: string | null; gottesdienstzeitenId: string | null; discovermassId: string | null; + buscarmisasNetworkId: string | null; source: string; website: string | null; phone: string | null; @@ -138,6 +139,7 @@ export type ChurchCandidate = { kerknetId?: string; gottesdienstzeitenId?: string; discovermassId?: string; + buscarmisasNetworkId?: string; }; /** @@ -147,8 +149,8 @@ export type ChurchCandidate = { * Matching strategy (in priority order): * 1. Exact osmId match * 2. Exact baiduId match - * 3-14. Exact importer ID matches (orarimesse, massSchedulesPh, philmass, horariosMisas, mszeInfo, weekdayMasses, messesInfo, bohosluzby, miserend, kerknet, gottesdienstzeiten, discovermass) - * 15. Proximity + name similarity (within 200m + similar name) + * 3-9. Exact importer ID matches (orarimesse, massSchedulesPh, philmass, horariosMisas, mszeInfo, weekdayMasses, messesInfo) + * 10. Proximity + name similarity (within 200m + similar name) */ export function findDuplicateChurch( candidate: ChurchCandidate, @@ -260,11 +262,21 @@ export function findDuplicateChurch( // Fourteenth pass: exact discovermassId match if (candidate.discovermassId) { - const match = existingChurches.find(c => c.discovermassId === candidate.discovermassId); + const match = existingChurches.find( + (church) => church.discovermassId === candidate.discovermassId + ); if (match) return match; } - // Fifteenth pass: proximity + name match (skip if candidate has no real coordinates) + // Fifteenth pass: exact buscarmisasNetworkId match + if (candidate.buscarmisasNetworkId) { + const match = existingChurches.find( + (church) => church.buscarmisasNetworkId === candidate.buscarmisasNetworkId + ); + if (match) return match; + } + + // Sixteenth pass: proximity + name match (skip if candidate has no real coordinates) if (candidate.lat === 0 && candidate.lng === 0) { return null; }