Browse Source

Change query to use `terms` and add code coverage stats

pull/115/head
Diana Shkolnikov 10 years ago
parent
commit
7b5a2fafb9
  1. 2
      .gitignore
  2. 1
      .jshintignore
  3. 5
      .travis.yml
  4. 4
      README.md
  5. 4
      package.json
  6. 12
      query/reverse.js
  7. 13
      test/unit/query/reverse.js

2
.gitignore vendored

@ -1,2 +1,4 @@
node_modules node_modules
coverage
.idea
*.log *.log

1
.jshintignore

@ -1 +1,2 @@
node_modules node_modules
coverage

5
.travis.yml

@ -2,3 +2,8 @@ language: node_js
script: "npm run unit" script: "npm run unit"
node_js: node_js:
- "0.10" - "0.10"
addons:
code_climate:
repo_token: a98bd9004512c8caf44e5cb2b3586d01baf190ee069ec0b731b451fc9966e639
after_script:
- codeclimate < coverage/lcov.info

4
README.md

@ -1,6 +1,10 @@
# API # 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) [![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 Pelias RESTful API
## Documentation ## Documentation

4
package.json

@ -8,9 +8,10 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
"test": "npm run unit", "test": "npm run unit && npm run coverage",
"unit": "node test/unit/run.js | tap-spec", "unit": "node test/unit/run.js | tap-spec",
"ciao": "node node_modules/ciao/bin/ciao -c test/ciao.json test/ciao", "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;", "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" "docs": "rm -r docs; cd test/ciao; node ../../node_modules/ciao/bin/ciao -c ../ciao.json . -d ../../docs"
}, },
@ -44,6 +45,7 @@
}, },
"devDependencies": { "devDependencies": {
"ciao": "^0.3.4", "ciao": "^0.3.4",
"istanbul": "^0.3.13",
"jshint": "^2.5.6", "jshint": "^2.5.6",
"nsp": "^0.3.0", "nsp": "^0.3.0",
"precommit-hook": "^1.0.7", "precommit-hook": "^1.0.7",

12
query/reverse.js

@ -20,15 +20,9 @@ function generate( params ){
} }
function addCategoriesFilter( query, categories ) { function addCategoriesFilter( query, categories ) {
query.query.filtered.query = { query.query.filtered.filter.bool.must.push({
match: { terms: { category: categories }
category: { });
query: categories.join(' '),
analyzer: 'standard',
operator: 'or'
}
}
};
} }
module.exports = generate; module.exports = generate;

13
test/unit/query/reverse.js

@ -120,13 +120,7 @@ module.exports.tests.query = function(test, common) {
'query': { 'query': {
'filtered': { 'filtered': {
'query': { 'query': {
'match': { 'match_all': {}
'category': {
'query': 'food education entertainment',
'analyzer': 'standard',
'operator': 'or'
}
}
}, },
'filter': { 'filter': {
'bool': { 'bool': {
@ -142,6 +136,11 @@ module.exports.tests.query = function(test, common) {
'lon': '-82.51' 'lon': '-82.51'
} }
} }
},
{
'terms': {
'category': params.categories
}
} }
] ]
} }

Loading…
Cancel
Save