diff --git a/.gitignore b/.gitignore index ab05030f..e84bbfbc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules +coverage +.idea *.log \ No newline at end of file diff --git a/.jshintignore b/.jshintignore index 3c3629e6..ba2a97b5 100644 --- a/.jshintignore +++ b/.jshintignore @@ -1 +1,2 @@ node_modules +coverage diff --git a/.travis.yml b/.travis.yml index 82ec939c..0d65b3bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,9 @@ language: node_js script: "npm run unit" node_js: - - "0.10" \ No newline at end of file + - "0.10" +addons: + code_climate: + repo_token: a98bd9004512c8caf44e5cb2b3586d01baf190ee069ec0b731b451fc9966e639 +after_script: + - codeclimate < coverage/lcov.info \ No newline at end of file diff --git a/README.md b/README.md index 01da637a..71cd6c97 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # API [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/pelias/api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Code Climate](https://codeclimate.com/github/pelias/api/badges/gpa.svg)](https://codeclimate.com/github/pelias/api) + +[![Test Coverage](https://codeclimate.com/github/pelias/api/badges/coverage.svg)](https://codeclimate.com/github/pelias/api) + Pelias RESTful API ## Documentation diff --git a/package.json b/package.json index 0276211e..4f35bbe2 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,10 @@ "main": "index.js", "scripts": { "start": "node index.js", - "test": "npm run unit", + "test": "npm run unit && npm run coverage", "unit": "node test/unit/run.js | tap-spec", "ciao": "node node_modules/ciao/bin/ciao -c test/ciao.json test/ciao", + "coverage": "node_modules/.bin/istanbul cover test/unit/run.js", "audit": "npm shrinkwrap; node node_modules/nsp/bin/nspCLI.js audit-shrinkwrap; rm npm-shrinkwrap.json;", "docs": "rm -r docs; cd test/ciao; node ../../node_modules/ciao/bin/ciao -c ../ciao.json . -d ../../docs" }, @@ -44,6 +45,7 @@ }, "devDependencies": { "ciao": "^0.3.4", + "istanbul": "^0.3.13", "jshint": "^2.5.6", "nsp": "^0.3.0", "precommit-hook": "^1.0.7", diff --git a/query/reverse.js b/query/reverse.js index 185d312d..499ddddc 100644 --- a/query/reverse.js +++ b/query/reverse.js @@ -20,15 +20,9 @@ function generate( params ){ } function addCategoriesFilter( query, categories ) { - query.query.filtered.query = { - match: { - category: { - query: categories.join(' '), - analyzer: 'standard', - operator: 'or' - } - } - }; + query.query.filtered.filter.bool.must.push({ + terms: { category: categories } + }); } module.exports = generate; \ No newline at end of file diff --git a/test/unit/query/reverse.js b/test/unit/query/reverse.js index a2878e94..00a3d15e 100644 --- a/test/unit/query/reverse.js +++ b/test/unit/query/reverse.js @@ -120,13 +120,7 @@ module.exports.tests.query = function(test, common) { 'query': { 'filtered': { 'query': { - 'match': { - 'category': { - 'query': 'food education entertainment', - 'analyzer': 'standard', - 'operator': 'or' - } - } + 'match_all': {} }, 'filter': { 'bool': { @@ -142,6 +136,11 @@ module.exports.tests.query = function(test, common) { 'lon': '-82.51' } } + }, + { + 'terms': { + 'category': params.categories + } } ] }