Skip to content

Commit

Permalink
Merge pull request #132 from pelias/deduplicate-phrase
Browse files Browse the repository at this point in the history
fix(deduplication): Deduplicate values in phrase field
  • Loading branch information
orangejulius authored Jun 10, 2020
2 parents e60b0ca + 155b762 commit 9c8379d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions post/deduplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

const _ = require('lodash');
const prefixes = [ 'name', 'address_parts' ];
const prefixes = [ 'name', 'phrase', 'address_parts' ];

function deduplication( doc ){
prefixes.forEach(prefix => {
Expand All @@ -20,4 +20,4 @@ function deduplication( doc ){
});
}

module.exports = deduplication;
module.exports = deduplication;
15 changes: 15 additions & 0 deletions test/post/deduplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ module.exports.tests.dedupe = function (test) {

t.end();
});

test('dedupe - phrase', function (t) {
var doc = new Document('mysource', 'mylayer', 'myid');

doc.setNameAlias('default', 'test');
doc.setName('default', 'test');
doc.setNameAlias('default', 'test');
doc.setNameAlias('default', 'test 2');
doc.setNameAlias('default', 'test');

deduplication(doc);
t.deepEquals(doc.phrase.default, ['test', 'test 2']);

t.end();
});
};

module.exports.all = function (tape, common) {
Expand Down

0 comments on commit 9c8379d

Please sign in to comment.