Skip to content

Commit de5a284

Browse files
authored
Branch was updated using the 'autoupdate branch' Actions workflow.
2 parents e36536e + 57e1a1b commit de5a284

4 files changed

Lines changed: 6 additions & 45 deletions

File tree

javascripts/experiment.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,4 @@ export default function () {
2727
// const x = document.querySelector(...)
2828
// x.addEventListener('click', () => { sendSuccess(testName) })
2929
// if (xbucket === TREATMENT) applyTreatment(x)
30-
31-
const testName = 'search_lunr'
32-
const xbucket = bucket(testName)
33-
document.addEventListener('click', evt => {
34-
if (!evt.target.closest('.search-result > a')) return
35-
console.log(testName, xbucket) // eslint-disable-line
36-
sendSuccess(testName)
37-
})
38-
// Treatment code in middleware/search.js
3930
}

lib/search/lunr-search.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const LUNR_DIR = './indexes'
1515
const lunrIndexes = new Map()
1616
const lunrRecords = new Map()
1717

18-
async function loadLunrResults ({ version, language, query, limit }) {
18+
module.exports = async function loadLunrResults ({ version, language, query, limit }) {
1919
const indexName = `${namePrefix}-${version}-${language}`
2020
if (!lunrIndexes.has(indexName) || !lunrRecords.has(indexName)) {
2121
lunrIndexes.set(indexName, await loadLunrIndex(indexName))
@@ -39,15 +39,6 @@ async function loadLunrResults ({ version, language, query, limit }) {
3939
return results
4040
}
4141

42-
loadLunrResults.warmLunr = async function warmLunr () {
43-
// Took about 60 seconds on local to warm them all...
44-
// so doing just the most common for prewarming
45-
const indexName = 'github-docs-dotcom-en'
46-
lunrRecords.set(indexName, await loadLunrRecords(indexName))
47-
lunrIndexes.set(indexName, await loadLunrIndex(indexName))
48-
return true
49-
}
50-
5142
async function loadLunrIndex (indexName) {
5243
const filePath = path.posix.join(__dirname, LUNR_DIR, `${indexName}.json.br`)
5344
// Do not set to 'utf8' on file reads
@@ -97,5 +88,3 @@ function field (result, record, name) {
9788
function mark (text) {
9889
return `<mark>${text}</mark>`
9990
}
100-
101-
module.exports = loadLunrResults

lib/warm-server.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const { loadPages, loadPageMap } = require('./pages')
33
const loadRedirects = require('./redirects/precompile')
44
const loadSiteData = require('./site-data')
55
const loadSiteTree = require('./site-tree')
6-
const { warmLunr } = require('./search/lunr-search')
76

87
// Instrument these functions so that
98
// it's wrapped in a timer that reports to Datadog
@@ -12,16 +11,15 @@ const dog = {
1211
loadPageMap: statsd.asyncTimer(loadPageMap, 'load_page_map'),
1312
loadRedirects: statsd.asyncTimer(loadRedirects, 'load_redirects'),
1413
loadSiteData: statsd.timer(loadSiteData, 'load_site_data'),
15-
loadSiteTree: statsd.asyncTimer(loadSiteTree, 'load_site_tree'),
16-
warmLunr: statsd.asyncTimer(warmLunr, 'warm_lunr')
14+
loadSiteTree: statsd.asyncTimer(loadSiteTree, 'load_site_tree')
1715
}
1816

1917
// For local caching
20-
let pageList, pageMap, site, redirects, siteTree, isLunrWarmed
18+
let pageList, pageMap, site, redirects, siteTree
2119

2220
function isFullyWarmed () {
2321
// NOTE: Yes, `pageList` is specifically excluded here as it is transient data
24-
const fullyWarmed = !!(pageMap && site && redirects && siteTree && isLunrWarmed)
22+
const fullyWarmed = !!(pageMap && site && redirects && siteTree)
2523
return fullyWarmed
2624
}
2725

@@ -30,8 +28,7 @@ function getWarmedCache () {
3028
pages: pageMap,
3129
site,
3230
redirects,
33-
siteTree,
34-
isLunrWarmed
31+
siteTree
3532
}
3633
}
3734

@@ -62,10 +59,6 @@ async function warmServer () {
6259
siteTree = await dog.loadSiteTree(pageMap, site, redirects)
6360
}
6461

65-
if (!isLunrWarmed) {
66-
isLunrWarmed = /* await */ dog.warmLunr()
67-
}
68-
6962
if (process.env.NODE_ENV !== 'test') {
7063
console.log(`Context primed in ${Date.now() - startTime} ms`)
7164
}

middleware/search.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ const versions = new Set(Object.values(require('../lib/search/versions')))
44
const loadLunrResults = require('../lib/search/lunr-search')
55
const loadAlgoliaResults = require('../lib/search/algolia-search')
66

7-
// temp
8-
const murmur = require('imurmurhash')
9-
// end temp
10-
117
const router = express.Router()
128

139
router.get('/', async function postSearch (req, res, next) {
@@ -25,16 +21,8 @@ router.get('/', async function postSearch (req, res, next) {
2521
return res.status(200).json([])
2622
}
2723

28-
// temp
29-
const userEventsId = req.cookies['_docs-events']
30-
const experimentHash = userEventsId
31-
? murmur('search_lunr').hash(userEventsId).result()
32-
: 0
33-
const inTreatment = experimentHash % 2
34-
// end temp
35-
3624
try {
37-
const results = process.env.AIRGAP || req.cookies.AIRGAP || inTreatment
25+
const results = process.env.AIRGAP || req.cookies.AIRGAP
3826
? await loadLunrResults({ version, language, query: `${query} ${filters || ''}`, limit })
3927
: await loadAlgoliaResults({ version, language, query, filters, limit })
4028
return res.status(200).json(results)

0 commit comments

Comments
 (0)