File tree Expand file tree Collapse file tree 1 file changed +17
-18
lines changed
Expand file tree Collapse file tree 1 file changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -171,29 +171,28 @@ function isAddressDifferent(item1, item2){
171171}
172172
173173function isGeonamesConcordanceSame ( item1 , item2 ) {
174- let wof_record ;
175- let gn_record ;
176-
177- if ( item1 . source === 'geonames' && item2 . source === 'whosonfirst' ) {
178- gn_record = item1 ;
179- wof_record = item2 ;
180- } else if ( item2 . source === 'geonames' && item1 . source === 'whosonfirst' ) {
181- gn_record = item2 ;
182- wof_record = item1 ;
183- } else {
184- // could not match to one geonames and one wof concordance, so this check does not apply
174+ const items = [ item1 , item2 ] ;
175+
176+ const wof_record = items . find ( i => i . source === 'whosonfirst' ) ;
177+ const gn_record = items . find ( i => i . source === 'geonames' ) ;
178+
179+ // must have found one wof and one gn record or this check does not apply
180+ if ( ! wof_record || ! gn_record ) { return false ; }
181+
182+ const concordances = _ . get ( wof_record , 'addendum.concordances' ) ;
183+
184+ if ( ! concordances ) {
185185 return false ;
186186 }
187187
188- const concordances = _ . get ( wof_record , 'addendum.concordances' ) ;
188+ const json = codec . decode ( concordances ) ;
189+ const concordance_id = json [ 'gn:id' ] ;
189190
190- if ( concordances ) {
191- const json = codec . decode ( concordances ) ;
192- const concordance_id = json [ 'gn:id' ] ;
191+ if ( ! concordance_id || ! _ . isNumber ( concordance_id ) ) { return false ; }
193192
194- if ( concordance_id && typeof concordance_id === 'number' && concordance_id . toString ( ) === gn_record . source_id ) {
195- return true ;
196- }
193+ // only records with a matching concordance pass this check
194+ if ( concordance_id . toString ( ) === gn_record . source_id ) {
195+ return true ;
197196 }
198197
199198 return false ;
You can’t perform that action at this time.
0 commit comments