Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update popularity value from 'misc:photo_sum' to 'qs:photo_sum' #547

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/components/extractFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
};
Expand Down
4 changes: 2 additions & 2 deletions test/components/extractFieldsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tape('readStreamComponents', function(test) {
}
],
'wof:abbreviation': 'XY',
'misc:photo_sum': 87654,
'qs:photo_sum': 87654,
ignoreField3: 'ignoreField3',
ignoreField4: 'ignoreField4',
}
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/readStreamTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
]);
Expand All @@ -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
}
},
{
Expand Down