diff --git a/CHANGELOG.md b/CHANGELOG.md index 75ab0f032..9dc813ba0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ _Breaking developer changes, which may affect downstream projects or sites that * Always render `ref` tag as label ([#9054], thanks [@k-yle]) * Remember last map location when no location is externally specified ([#7790], thanks [@bvercelli99]) * Add a `crossing=traffic_signals` tag to the intersection node when using _connect features_ of a _crossing with pedestrian signals_ way in the validator ([#9176], thanks [@faebebin]) +* Don't auto-suggest tag values which have fewer than 100 uses ([#9227]) #### :bug: Bugfixes * When typing an invalid unit into the Speed Limit or Max Height field, revert to the previous unit ([#9110], thanks [@1ec5]) * Fix wikidata field displaying `[object Object]` instead of item labels after wikibase API change ([#9067]) @@ -93,6 +94,7 @@ _Breaking developer changes, which may affect downstream projects or sites that [#9171]: https://github.com/openstreetmap/iD/pull/9171 [#9172]: https://github.com/openstreetmap/iD/pull/9172 [#9208]: https://github.com/openstreetmap/iD/issues/9208 +[#9227]: https://github.com/openstreetmap/iD/issues/9227 [@furkanmutlu]: https://github.com/furkanmutlu [@JackNUMBER]: https://github.com/JackNUMBER [@aaditya0000]: https://github.com/aaditya0000 diff --git a/modules/services/taginfo.js b/modules/services/taginfo.js index 4781c3ce5..bfbb4d56a 100644 --- a/modules/services/taginfo.js +++ b/modules/services/taginfo.js @@ -89,7 +89,7 @@ function filterValues(allowUpperCase) { return function(d) { if (d.value.match(/[;,]/) !== null) return false; // exclude some punctuation if (!allowUpperCase && d.value.match(/[A-Z*]/) !== null) return false; // exclude uppercase letters - return parseFloat(d.fraction) > 0.0; + return d.count > 100 || d.in_wiki; // exclude rare undocumented tags }; } @@ -116,9 +116,6 @@ function valKeyDescription(d) { value: d.value, title: d.description || d.value }; - if (d.count) { - obj.count = d.count; - } return obj; } diff --git a/modules/ui/fields/combo.js b/modules/ui/fields/combo.js index 482332d44..404ba93df 100644 --- a/modules/ui/fields/combo.js +++ b/modules/ui/fields/combo.js @@ -189,14 +189,8 @@ export function uiFieldCombo(field, context) { if (err) return; data = data.filter(function(d) { - - if (field.type === 'typeCombo' && d.value === 'yes') { - // don't show the fallback value - return false; - } - - // don't show values with very low usage - return !d.count || d.count > 10; + // don't show the fallback value + return field.type !== 'typeCombo' || d.value !== 'yes'; }); var deprecatedValues = osmEntity.deprecatedTagValuesByKey(_dataDeprecated)[field.key]; diff --git a/test/spec/services/taginfo.js b/test/spec/services/taginfo.js index f25e3471c..cdb35deac 100644 --- a/test/spec/services/taginfo.js +++ b/test/spec/services/taginfo.js @@ -196,7 +196,7 @@ describe('iD.serviceTaginfo', function() { describe('#values', function() { it('calls the given callback with the results of the values query', function(done) { fetchMock.mock(/\/key\/values/, { - body: '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":0.1}]}', + body: '{"data":[{"value":"parking","description":"A place for parking cars", "count":1000}]}', status: 200, headers: { 'Content-Type': 'application/json' } }); @@ -217,8 +217,8 @@ describe('iD.serviceTaginfo', function() { it('includes popular values', function(done) { fetchMock.mock(/\/key\/values/, { - body: '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":1.0},' + - '{"value":"party","description":"A place for partying", "fraction":0.0}]}', + body: '{"data":[{"value":"parking","description":"A place for parking cars", "count":1000},' + + '{"value":"party","description":"A place for partying", "count":1}]}', status: 200, headers: { 'Content-Type': 'application/json' } }); @@ -236,8 +236,8 @@ describe('iD.serviceTaginfo', function() { it('does not get values for extremely unpopular keys', function(done) { fetchMock.mock(/\/key\/values/, { - body: '{"data":[{"value":"Rue Pasteur","description":"", "fraction":0.0001},' + - '{"value":"Via Trieste","description":"", "fraction":0.0001}]}', + body: '{"data":[{"value":"Rue Pasteur","description":"", "count":3},' + + '{"value":"Via Trieste","description":"", "count":1}]}', status: 200, headers: { 'Content-Type': 'application/json' } }); @@ -251,13 +251,31 @@ describe('iD.serviceTaginfo', function() { }, 50); }); + it('includes unpopular values with a wiki page', function(done) { + fetchMock.mock(/\/key\/values/, { + body: '{"data":[{"value":"party","description":"A place for partying", "count":1, "in_wiki": true}]}', + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + + var callback = sinon.spy(); + taginfo.values({ key: 'amenity', query: 'par' }, callback); + + window.setTimeout(function() { + expect(callback).to.have.been.calledWith( + null, [{'value':'party','title':'A place for partying'}] + ); + done(); + }, 50); + }); + it('excludes values with capital letters and some punctuation', function(done) { fetchMock.mock(/\/key\/values/, { - body: '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":0.2},' - + '{"value":"PArking","description":"A common misspelling", "fraction":0.2},' - + '{"value":"parking;partying","description":"A place for parking cars *and* partying", "fraction":0.2},' - + '{"value":"parking, partying","description":"A place for parking cars *and* partying", "fraction":0.2},' - + '{"value":"*","description":"", "fraction":0.2}]}', + body: '{"data":[{"value":"parking","description":"A place for parking cars", "count":2000},' + + '{"value":"PArking","description":"A common misspelling", "count":200},' + + '{"value":"parking;partying","description":"A place for parking cars *and* partying", "count":200},' + + '{"value":"parking, partying","description":"A place for parking cars *and* partying", "count":200},' + + '{"value":"*","description":"", "count":200}]}', status: 200, headers: { 'Content-Type': 'application/json' } }); @@ -275,11 +293,11 @@ describe('iD.serviceTaginfo', function() { it('includes network values with capital letters and some punctuation', function(done) { fetchMock.mock(/\/key\/values/, { - body: '{"data":[{"value":"US:TX:FM","description":"Farm to Market Roads in the U.S. state of Texas.", "fraction":0.34},' - + '{"value":"US:KY","description":"Primary and secondary state highways in the U.S. state of Kentucky.", "fraction":0.31},' - + '{"value":"US:US","description":"U.S. routes in the United States.", "fraction":0.19},' - + '{"value":"US:I","description":"Interstate highways in the United States.", "fraction":0.11},' - + '{"value":"US:MD","description":"State highways in the U.S. state of Maryland.", "fraction":0.06}]}', + body: '{"data":[{"value":"US:TX:FM","description":"Farm to Market Roads in the U.S. state of Texas.", "count":34000},' + + '{"value":"US:KY","description":"Primary and secondary state highways in the U.S. state of Kentucky.", "count":31000},' + + '{"value":"US:US","description":"U.S. routes in the United States.", "count":19000},' + + '{"value":"US:I","description":"Interstate highways in the United States.", "count":11000},' + + '{"value":"US:MD","description":"State highways in the U.S. state of Maryland.", "count":600}]}', status: 200, headers: { 'Content-Type': 'application/json' } }); @@ -301,7 +319,7 @@ describe('iD.serviceTaginfo', function() { it('includes biological genus values with capital letters', function(done) { fetchMock.mock(/\/key\/values/, { - body: '{"data":[{"value":"Quercus","description":"Oak", "fraction":0.5}]}', + body: '{"data":[{"value":"Quercus","description":"Oak", "count": 1000}]}', status: 200, headers: { 'Content-Type': 'application/json' } }); @@ -319,7 +337,7 @@ describe('iD.serviceTaginfo', function() { it('includes biological taxon values with capital letters', function(done) { fetchMock.mock(/\/key\/values/, { - body: '{"data":[{"value":"Quercus robur","description":"Oak", "fraction":0.5}]}', + body: '{"data":[{"value":"Quercus robur","description":"Oak", "count": 1000}]}', status: 200, headers: { 'Content-Type': 'application/json' } }); @@ -337,7 +355,7 @@ describe('iD.serviceTaginfo', function() { it('includes biological species values with capital letters', function(done) { fetchMock.mock(/\/key\/values/, { - body: '{"data":[{"value":"Quercus robur","description":"Oak", "fraction":0.5}]}', + body: '{"data":[{"value":"Quercus robur","description":"Oak", "count": 1000}]}', status: 200, headers: { 'Content-Type': 'application/json' } });