Skip to content

Commit

Permalink
makes infinitesimal perf improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmullen committed May 19, 2022
1 parent 6ce0ad6 commit bcdf157
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/cms/src/api/searchRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {CANON_CMS_CUBES, CANON_CMS_MINIMUM_ROLE, OLAP_PROXY_SECRET, CANON_CMS_LUN
process.env;

const verbose = yn(process.env.CANON_CMS_LOGGING);
const useLUNR = yn(CANON_CMS_LUNR);
let Base58, flickr, sharp, storage;
if (process.env.FLICKR_API_KEY) {
const Flickr = require("flickr-sdk");
Expand Down Expand Up @@ -578,7 +579,7 @@ module.exports = function(app) {
let contentIds = [];
const {searchIndexByLocale} = app.settings.cache;

if (yn(CANON_CMS_LUNR) && searchIndexByLocale[locale]) {
if (useLUNR && searchIndexByLocale[locale]) {
const terms = query.split(" ").map(d => `+${d}~1*`).join(" ");
const lunrResults = searchIndexByLocale[locale].search(terms);
contentIds = lunrResults.map(d => d.ref);
Expand Down
4 changes: 3 additions & 1 deletion packages/cms/src/cache/searchIndexByLocale.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const {CANON_LANGUAGES, CANON_CMS_LUNR} = process.env;

const locales = CANON_LANGUAGES ? CANON_LANGUAGES.split(",").filter(d => whitelist.includes(d)) : [];

for (const locale of locales.filter(d => d !== "en")) {
const nonEnLocales = locales.filter(d => d !== "en");

for (const locale of nonEnLocales) {
require(`lunr-languages/lunr.${locale}`)(lunr);
}

Expand Down

0 comments on commit bcdf157

Please sign in to comment.