summaryrefslogtreecommitdiff
path: root/bucky/search
diff options
context:
space:
mode:
Diffstat (limited to 'bucky/search')
-rw-r--r--bucky/search/bdb.js55
-rw-r--r--bucky/search/search.js5
-rw-r--r--bucky/search/snippet.js2
3 files changed, 1 insertions, 61 deletions
diff --git a/bucky/search/bdb.js b/bucky/search/bdb.js
deleted file mode 100644
index 6f1fd98..0000000
--- a/bucky/search/bdb.js
+++ /dev/null
@@ -1,55 +0,0 @@
-var bdb_lib = require('berkeleydb')
-var dbenv = new bdb_lib.DbEnv();
-var bdb_status = dbenv.open('./search/db/env')
-if (bdb_status) {
- console.log('open dbenv failed:', bdb_status)
- process.exit()
-}
-
-function db(fn){
- var db
- fn = "./" + fn + ".db"
-
- function exitHandler(options, err) {
- if (db) db.close()
- // if (options.cleanup) console.log('clean');
- if (err) console.log(err.stack);
- if (options.exit) process.exit();
- }
-
- // do something when app is closing
- process.on('exit', exitHandler.bind(null, {cleanup: true}));
-
- // catches ctrl+c event
- process.on('SIGINT', exitHandler.bind(null, {exit: true}));
-
- // catches "kill pid" (for example: nodemon restart)
- process.on('SIGUSR1', exitHandler.bind(null, {exit: true}));
- process.on('SIGUSR2', exitHandler.bind(null, {exit: true}));
-
- //catches uncaught exceptions
- process.on('uncaughtException', exitHandler.bind(null, {exit:true}));
-
- function open(fn){
- if (db) db.close()
- var _db = new bdb_lib.Db(dbenv);
- var bdb_status = _db.open(fn)
- if (bdb_status) {
- console.log('openĀ ' + fn + ' failed:', bdb_status)
- process.exit()
- }
- db = _db
- }
-
- open(fn)
-
- return {
- put: function(term, serialized){
- db.put(term, serialized)
- },
- get: function(term){
- return db.get(term)
- },
- }
-}
-module.exports = db
diff --git a/bucky/search/search.js b/bucky/search/search.js
index bde1ad9..9891963 100644
--- a/bucky/search/search.js
+++ b/bucky/search/search.js
@@ -42,13 +42,10 @@ function search (query, start, limit, cb) {
var results = []
- console.log(terms)
eachSeries(
terms,
function(term, callback){
- console.log(term);
if (STOPWORDS.has(term)) return;
- console.log("howdy")
redisClient.get(term, function(err, results){
// if (!results) return callback();
@@ -73,13 +70,11 @@ function search (query, start, limit, cb) {
if (i < start) return false
if (to_display-- === 0) return true
results.push(match)
- // console.log(match)
thread_ids.push(match.thread)
if (match.comment) comment_ids.push(match.comment)
if (match.file) file_ids.push(match.file)
return false
})
- //console.log(results)
redisClient.quit()
cb( {
meta: {
diff --git a/bucky/search/snippet.js b/bucky/search/snippet.js
index 17988d2..f8fd12f 100644
--- a/bucky/search/snippet.js
+++ b/bucky/search/snippet.js
@@ -78,4 +78,4 @@ function snippet(s, terms) {
return snippet
}
-module.exports = snippet \ No newline at end of file
+module.exports = snippet