From 20da26d7cfb66704faf505d83b2f0a761f6c6722 Mon Sep 17 00:00:00 2001 From: arnesetzer <25772747+arnesetzer@users.noreply.github.com> Date: Fri, 23 Aug 2024 12:26:41 +0200 Subject: [PATCH 1/2] Update popularity value from 'misc:photo_sum' to 'qs:photo_sum' --- src/components/extractFields.js | 14 +++++++++++++- test/components/extractFieldsTest.js | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/extractFields.js b/src/components/extractFields.js index 4865d8b2..ba1a9413 100644 --- a/src/components/extractFields.js +++ b/src/components/extractFields.js @@ -212,6 +212,18 @@ function getConcordances(properties) { return concordances; } +//Update the popularity value field due to https://github.com/whosonfirst-data/whosonfirst-data/pull/979 +function getPopularity(properties) { + if (!_.isEmpty(properties, 'qs:photo_sum')) { + return properties['qs:photo_sum']; + } + //Legacy support + if (!_.isEmpty(properties, 'misc:photo_sum')) { + return properties['misc:photo_sum']; + } + return undefined; +} + /* This function extracts the fields from the json_object that we're interested in for creating Pelias Document objects. If there is no hierarchy then a @@ -232,7 +244,7 @@ module.exports.create = function map_fields_stream() { lon: getLon(json_object.properties), bounding_box: getBoundingBox(json_object.properties), population: getPopulation(json_object.properties), - popularity: json_object.properties['misc:photo_sum'], + popularity: getPopularity(json_object.properties), hierarchies: getHierarchies(json_object.id, json_object.properties), concordances: getConcordances(json_object.properties) }; diff --git a/test/components/extractFieldsTest.js b/test/components/extractFieldsTest.js index ec3d9887..d0b781eb 100644 --- a/test/components/extractFieldsTest.js +++ b/test/components/extractFieldsTest.js @@ -43,7 +43,7 @@ tape('readStreamComponents', function(test) { } ], 'wof:abbreviation': 'XY', - 'misc:photo_sum': 87654, + 'qs:photo_sum': 87654, ignoreField3: 'ignoreField3', ignoreField4: 'ignoreField4', } @@ -182,7 +182,7 @@ tape('readStreamComponents', function(test) { }); - test.test('misc:photo_sum not found should not include popularity', function(t) { + test.test('qs:photo_sum not found should not include popularity', function(t) { var input = [ { id: 12345, From 3e63000d45b5ab8a8c85d6d0462eee23ec7ad46b Mon Sep 17 00:00:00 2001 From: arnesetzer <25772747+arnesetzer@users.noreply.github.com> Date: Fri, 23 Aug 2024 12:39:10 +0200 Subject: [PATCH 2/2] Fix other half of test --- test/readStreamTest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/readStreamTest.js b/test/readStreamTest.js index 8aec9a84..c22f729f 100644 --- a/test/readStreamTest.js +++ b/test/readStreamTest.js @@ -25,7 +25,7 @@ tape('readStream', (test) => { 'wof:abbreviation': 'XY', 'geom:bbox': '-13.691314,49.909613,1.771169,60.847886', 'gn:population': 98765, - 'misc:photo_sum': 87654 + 'qs:photo_sum': 87654 } } ]); @@ -41,7 +41,7 @@ tape('readStream', (test) => { 'wof:abbreviation': 'XY', 'geom:bbox': '-13.691314,49.909613,1.771169,60.847886', 'gn:population': 98765, - 'misc:photo_sum': 87654 + 'qs:photo_sum': 87654 } }, {