Skip to content
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.

Commit

Permalink
📉 allow results limit to be set from env
Browse files Browse the repository at this point in the history
  • Loading branch information
beseven committed Aug 7, 2017
1 parent d895093 commit a646b66
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 62 deletions.
7 changes: 7 additions & 0 deletions .snyk
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,11 @@ ignore:
- nunjucks > chokidar > fsevents > node-pre-gyp > request > qs:
reason: None given
expires: '2017-07-21T13:04:48.346Z'
'npm:tunnel-agent:20170305':
- node-sass > request > tunnel-agent:
reason: None given
expires: '2017-09-02T15:46:20.371Z'
- node-sass > node-gyp > request > tunnel-agent:
reason: None given
expires: '2017-09-02T15:46:20.371Z'
patch: {}
4 changes: 2 additions & 2 deletions app/middleware/getGps.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ function getEsQuery(postcodeLocationDetails, searchTerm, size) {
function getGps(req, res, next) {
const searchTerm = res.locals.search;
const postcode = res.locals.postcodeSearch;
const resultsReturnedCount = res.locals.resultsReturnedCount;
const resultsLimit = res.locals.RESULTS_LIMIT;
const postcodeLocationDetails = res.locals.postcodeLocationDetails;
const esQuery = getEsQuery(postcodeLocationDetails, searchTerm, resultsReturnedCount);
const esQuery = getEsQuery(postcodeLocationDetails, searchTerm, resultsLimit);

elasticsearchClient
.search(esQuery)
Expand Down
1 change: 1 addition & 0 deletions app/middleware/locals.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = config =>
res.locals.WEBTRENDS_ANALYTICS_TRACKING_ID = config.webtrendsId;
res.locals.HOTJAR_ANALYTICS_TRACKING_ID = config.hotjarId;
res.locals.SITE_ROOT = req.app.locals.SITE_ROOT;
res.locals.RESULTS_LIMIT = config.resultsLimit;
/* eslint-enable no-param-reassign */

next();
Expand Down
1 change: 0 additions & 1 deletion app/middleware/setLocals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const backLinkUtils = require('../lib/utils/backLink');
function fromRequest(req, res, next) {
res.locals.search = req.query.search;
res.locals.postcodeSearch = req.query.postcode;
res.locals.resultsReturnedCount = 30;
res.locals.resultsCount = 0;
res.locals.isOutcode = false;
res.locals.searchLabel = 'Surgery or GP name';
Expand Down
2 changes: 1 addition & 1 deletion app/views/results.nunjucks
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% block meta %}
<meta name="WT.gposs" content="{{ search }}"></meta>
<meta name="WT.gposs_r" content="1"></meta>
<meta name="DCSext.GPReturnedResults" content="{{ resultsReturnedCount }}"></meta>
<meta name="DCSext.GPResultsLimit" content="{{ RESULTS_LIMIT }}"></meta>
<meta name="DCSext.GPTotalResults" content="{{ resultsCount }}"></meta>
{% endblock %}

Expand Down
1 change: 1 addition & 0 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
host: process.env.ES_HOST || 'es',
port: process.env.ES_PORT || '9200',
},
resultsLimit: process.env.RESULTS_LIMIT || 30,
googleAnalyticsId: process.env.GOOGLE_ANALYTICS_TRACKING_ID,
webtrendsId: process.env.WEBTRENDS_ANALYTICS_TRACKING_ID,
hotjarId: process.env.HOTJAR_ANALYTICS_TRACKING_ID,
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"on-headers": "^1.0.1",
"postcodesio-client": "^0.2.0",
"require-environment-variables": "^1.1.2",
"tunnel-agent": "^0.6.0",
"verror": "^1.10.0"
},
"devDependencies": {
Expand Down
14 changes: 14 additions & 0 deletions test/integration/resultsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ describe('Results page', () => {
});
});

it('should contain meta data with results information', (done) => {
const search = 'Surgery';
const postcode = '';

assertSearchResponse(search, postcode, done, (err, res) => {
const $ = cheerio.load(res.text);
const resultsLimit = $('meta[name="DCSext.GPResultsLimit"]').attr('content');
const totalResults = $('meta[name="DCSext.GPTotalResults"]').attr('content');

expect(resultsLimit).to.eq('30');
expect(totalResults).to.eq('3687');
});
});

describe('matching surgeries found', () => {
describe('multiple matches', () => {
it('should have more than one result', (done) => {
Expand Down
110 changes: 53 additions & 57 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ acorn@^3.0.4:
version "3.3.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"

acorn@^5.0.1:
acorn@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.1.tgz#53fe161111f912ab999ee887a90a0bc52822fd75"

Expand Down Expand Up @@ -475,8 +475,8 @@ chai-string@^1.4.0:
resolved "https://registry.yarnpkg.com/chai-string/-/chai-string-1.4.0.tgz#359140c051d36a4e4b1a5fc6b910152f438a8d49"

chai@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.0.tgz#331a0391b55c3af8740ae9c3b7458bc1c3805e6d"
version "4.1.1"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.1.tgz#66e21279e6f3c6415ff8231878227900e2171b39"
dependencies:
assertion-error "^1.0.1"
check-error "^1.0.1"
Expand All @@ -496,8 +496,8 @@ chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3:
supports-color "^2.0.0"

chalk@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.0.1.tgz#dbec49436d2ae15f536114e76d14656cdbc0f44d"
version "2.1.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e"
dependencies:
ansi-styles "^3.1.0"
escape-string-regexp "^1.0.5"
Expand Down Expand Up @@ -755,8 +755,8 @@ cookiejar@2.0.x, cookiejar@^2.0.6:
resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.0.6.tgz#0abf356ad00d1c5a219d88d44518046dd026acfe"

core-js@^2.4.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e"
version "2.5.0"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.0.tgz#569c050918be6486b3837552028ae0466b717086"

core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
Expand Down Expand Up @@ -899,11 +899,7 @@ delegates@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"

depd@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.0.tgz#e1bd82c6aab6ced965b97b88b17ed3e528ca18c3"

depd@~1.1.0:
depd@1.1.1, depd@~1.1.0, depd@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359"

Expand Down Expand Up @@ -984,8 +980,8 @@ dot-prop@^3.0.0:
is-obj "^1.0.0"

dtrace-provider@~0.8:
version "0.8.4"
resolved "https://registry.yarnpkg.com/dtrace-provider/-/dtrace-provider-0.8.4.tgz#f27c12dc0ec3105606f9833c118b8d711c8d532a"
version "0.8.5"
resolved "https://registry.yarnpkg.com/dtrace-provider/-/dtrace-provider-0.8.5.tgz#98ebba221afac46e1c39fd36858d8f9367524b92"
dependencies:
nan "^2.3.3"

Expand Down Expand Up @@ -1150,8 +1146,8 @@ eslint-watch@^3.1.1:
unicons "0.0.3"

eslint@^4.2.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.3.0.tgz#fcd7c96376bbf34c85ee67ed0012a299642b108f"
version "4.4.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.4.0.tgz#a3e153e704b64f78290ef03592494eaba228d3bc"
dependencies:
ajv "^5.2.0"
babel-code-frame "^6.22.0"
Expand All @@ -1161,7 +1157,7 @@ eslint@^4.2.0:
debug "^2.6.8"
doctrine "^2.0.0"
eslint-scope "^3.7.1"
espree "^3.4.3"
espree "^3.5.0"
esquery "^1.0.0"
estraverse "^4.2.0"
esutils "^2.0.2"
Expand All @@ -1173,7 +1169,7 @@ eslint@^4.2.0:
imurmurhash "^0.1.4"
inquirer "^3.0.6"
is-resolvable "^1.0.0"
js-yaml "^3.8.4"
js-yaml "^3.9.1"
json-stable-stringify "^1.0.1"
levn "^0.3.0"
lodash "^4.17.4"
Expand All @@ -1190,11 +1186,11 @@ eslint@^4.2.0:
table "^4.0.1"
text-table "~0.2.0"

espree@^3.4.3:
version "3.4.3"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.3.tgz#2910b5ccd49ce893c2ffffaab4fd8b3a31b82374"
espree@^3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.0.tgz#98358625bdd055861ea27e2867ea729faf463d8d"
dependencies:
acorn "^5.0.1"
acorn "^5.1.1"
acorn-jsx "^3.0.0"

esprima@^2.6.0:
Expand Down Expand Up @@ -1267,32 +1263,32 @@ expect-ct@0.1.0:
resolved "https://registry.yarnpkg.com/expect-ct/-/expect-ct-0.1.0.tgz#52735678de18530890d8d7b95f0ac63640958094"

express@^4.15.2:
version "4.15.3"
resolved "https://registry.yarnpkg.com/express/-/express-4.15.3.tgz#bab65d0f03aa80c358408972fc700f916944b662"
version "4.15.4"
resolved "https://registry.yarnpkg.com/express/-/express-4.15.4.tgz#032e2253489cf8fce02666beca3d11ed7a2daed1"
dependencies:
accepts "~1.3.3"
array-flatten "1.1.1"
content-disposition "0.5.2"
content-type "~1.0.2"
cookie "0.3.1"
cookie-signature "1.0.6"
debug "2.6.7"
depd "~1.1.0"
debug "2.6.8"
depd "~1.1.1"
encodeurl "~1.0.1"
escape-html "~1.0.3"
etag "~1.8.0"
finalhandler "~1.0.3"
finalhandler "~1.0.4"
fresh "0.5.0"
merge-descriptors "1.0.1"
methods "~1.1.2"
on-finished "~2.3.0"
parseurl "~1.3.1"
path-to-regexp "0.1.7"
proxy-addr "~1.1.4"
qs "6.4.0"
proxy-addr "~1.1.5"
qs "6.5.0"
range-parser "~1.2.0"
send "0.15.3"
serve-static "1.12.3"
send "0.15.4"
serve-static "1.12.4"
setprototypeof "1.0.3"
statuses "~1.3.1"
type-is "~1.6.15"
Expand Down Expand Up @@ -1386,7 +1382,7 @@ finalhandler@1.0.3:
statuses "~1.3.1"
unpipe "~1.0.0"

finalhandler@~1.0.3:
finalhandler@~1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.0.4.tgz#18574f2e7c4b98b8ae3b230c21f201f31bdb3fb7"
dependencies:
Expand Down Expand Up @@ -1826,11 +1822,11 @@ htmlparser2@^3.9.1:
inherits "^2.0.1"
readable-stream "^2.0.2"

http-errors@~1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.1.tgz#5f8b8ed98aca545656bf572997387f904a722257"
http-errors@~1.6.1, http-errors@~1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736"
dependencies:
depd "1.1.0"
depd "1.1.1"
inherits "2.0.3"
setprototypeof "1.0.3"
statuses ">= 1.3.1 < 2"
Expand Down Expand Up @@ -2240,14 +2236,14 @@ js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"

js-yaml@3.6.1, js-yaml@3.x:
js-yaml@3.6.1:
version "3.6.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30"
dependencies:
argparse "^1.0.7"
esprima "^2.6.0"

js-yaml@^3.5.3, js-yaml@^3.7.0, js-yaml@^3.8.4:
js-yaml@3.x, js-yaml@^3.5.3, js-yaml@^3.7.0, js-yaml@^3.9.1:
version "3.9.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.9.1.tgz#08775cebdfdd359209f0d2acd383c8f86a6904a0"
dependencies:
Expand All @@ -2259,8 +2255,8 @@ jsbn@~0.1.0:
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"

jschardet@^1.4.2:
version "1.5.0"
resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-1.5.0.tgz#a61f310306a5a71188e1b1acd08add3cfbb08b1e"
version "1.5.1"
resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-1.5.1.tgz#c519f629f86b3a5bedba58a88d311309eec097f9"

jsesc@^1.3.0:
version "1.3.0"
Expand Down Expand Up @@ -2640,14 +2636,10 @@ mime-types@^2.1.10, mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.15,
dependencies:
mime-db "~1.29.0"

mime@1.3.4:
mime@1.3.4, mime@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53"

mime@^1.3.4:
version "1.3.6"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.6.tgz#591d84d3653a6b0b4a3b9df8de5aa8108e72e5e0"

mimic-fn@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18"
Expand Down Expand Up @@ -3213,7 +3205,7 @@ progress@^2.0.0:
dependencies:
asap "~2.0.3"

proxy-addr@~1.1.4:
proxy-addr@~1.1.5:
version "1.1.5"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.5.tgz#71c0ee3b102de3f202f3b64f608d173fcba1a918"
dependencies:
Expand Down Expand Up @@ -3242,10 +3234,14 @@ q@^1.1.2:
version "1.5.0"
resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1"

qs@6.4.0, qs@^6.1.0, qs@^6.2.0, qs@~6.4.0:
qs@6.4.0, qs@~6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"

qs@6.5.0, qs@^6.1.0, qs@^6.2.0:
version "6.5.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.0.tgz#8d04954d364def3efc55b5a0793e1e2c8b1e6e49"

qs@~6.3.0:
version "6.3.2"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c"
Expand Down Expand Up @@ -3591,32 +3587,32 @@ semver@~5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"

send@0.15.3:
version "0.15.3"
resolved "https://registry.yarnpkg.com/send/-/send-0.15.3.tgz#5013f9f99023df50d1bd9892c19e3defd1d53309"
send@0.15.4:
version "0.15.4"
resolved "https://registry.yarnpkg.com/send/-/send-0.15.4.tgz#985faa3e284b0273c793364a35c6737bd93905b9"
dependencies:
debug "2.6.7"
depd "~1.1.0"
debug "2.6.8"
depd "~1.1.1"
destroy "~1.0.4"
encodeurl "~1.0.1"
escape-html "~1.0.3"
etag "~1.8.0"
fresh "0.5.0"
http-errors "~1.6.1"
http-errors "~1.6.2"
mime "1.3.4"
ms "2.0.0"
on-finished "~2.3.0"
range-parser "~1.2.0"
statuses "~1.3.1"

serve-static@1.12.3:
version "1.12.3"
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.12.3.tgz#9f4ba19e2f3030c547f8af99107838ec38d5b1e2"
serve-static@1.12.4:
version "1.12.4"
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.12.4.tgz#9b6aa98eeb7253c4eedc4c1f6fdbca609901a961"
dependencies:
encodeurl "~1.0.1"
escape-html "~1.0.3"
parseurl "~1.3.1"
send "0.15.3"
send "0.15.4"

set-blocking@^2.0.0, set-blocking@~2.0.0:
version "2.0.0"
Expand Down

0 comments on commit a646b66

Please sign in to comment.